laravel

Laravel paginate resources won't add meta

烂漫一生 提交于 2021-02-05 07:26:05
问题 I have resources data returning in JSON. When I try to get my data with paginate it is not included meta data. Based on documentation my data supposed to be included meta like: "meta":{ "current_page": 1, "from": 1, "last_page": 1, "path": "http://example.com/pagination", "per_page": 15, "to": 10, "total": 10 } but my data is returning like this: Code controller public function index() { $products = ProductFrontResource::collection(Product::orderby('id', 'desc')->with(['photos', 'seo', 'tags'

How to send Multiple parameters in passes function of custom validation rule

自古美人都是妖i 提交于 2021-02-05 07:14:26
问题 I am implementing a custom validation rule which should take another parameter with attribute and value in passes function of custom validation rule. As we implement Rule interface while writing custom validations, it does not allow us to add third parameter in passes function but I need third parameter. Moreover, I will feel happy if anyone can guide me about the best practice of including database in rule. Either we should include only desired model in rule if we need a table in custom

Artisan won't connect to mysql - Laravel 4.2

流过昼夜 提交于 2021-02-05 07:11:10
问题 I cloned a project which is built on laravel 4.2. Currently my Xampp has a version 7.0.13.1 and has php version of 7.1. When i type php artisan migrate , it gives an error [PDOException] SQLSTATE[HY000] [2002] No such file or directory which means my artisan is not connected to my mysql running on the Xampp. In the terminal, i tried which php and i get /usr/local/php5/bin/php . Could this be the cause of my problem? That the path doesn't point to my Xampp version 7.0.13.1? PS: After cloning,

Query builder get array of results instead of objects in Laravel

一个人想着一个人 提交于 2021-02-05 07:10:46
问题 Here's my query DB::table('genres') ->join('albumGenres', 'genres.id', '=', 'albumGenres.genre_id') ->join('albums', 'albumGenres.album_id', '=', 'albums.id' ) ->select('genres.id') ->where('albumGenres.album_id','=',$this->id)->get(); But I get something like this "genre_id": [ { "id": "4" }, { "id": "8" } ] What should I do to get the results as just an array "genre_id" : [4,8] 回答1: With new versions of Laravel, you should use pluck() instead of lists(). DB::table('genres') ->join(

Artisan won't connect to mysql - Laravel 4.2

余生颓废 提交于 2021-02-05 07:10:04
问题 I cloned a project which is built on laravel 4.2. Currently my Xampp has a version 7.0.13.1 and has php version of 7.1. When i type php artisan migrate , it gives an error [PDOException] SQLSTATE[HY000] [2002] No such file or directory which means my artisan is not connected to my mysql running on the Xampp. In the terminal, i tried which php and i get /usr/local/php5/bin/php . Could this be the cause of my problem? That the path doesn't point to my Xampp version 7.0.13.1? PS: After cloning,

How do I authenticate a user in Laravel 8 Jetstream only if his status is active?

巧了我就是萌 提交于 2021-02-05 06:12:05
问题 I am building a Laravel 8 application and have successfully implemented authentication. Now I want to check if a user's status is active before logging him in. I have added a field in the users table username varchar password varchar .... status tinyint(1) ... I am using JetStream and Fortify Thank You 回答1: You can customize user authentication from app\Providers\JetStreamServiceProvider.php , on boot method : use App\Models\User; use Illuminate\Http\Request; use Laravel\Fortify\Fortify;

Is not deleting from bootstrap modal

陌路散爱 提交于 2021-02-05 05:52:25
问题 as you can see these code, the deleting button inside of pagination works fine without bootstrap modal, and then convert to bootstrap model, the bootstrap model is working fine once click the delete button, but the problem is not deleting it or do nothing. I can't figure out what I missing, I could be id number or jquery, I need help badly. Foreach <thead> <tr class="center"> <th>ID</th> <th>Account ID</th> <th>Password</th> <th>Company Name</th> <th>Restocking Fee</th> <th>Status</th> <th

Vue component not showing in laravel

会有一股神秘感。 提交于 2021-02-05 05:23:24
问题 So I'm trying to migrate my jquery to vue framework instead, I'm using laravel 5.6 with webpack to build my project but my vue components are not showing up. when I run command npm run dev I succesfully build the project: After that I use php artisan serve to show the web in my browser wich it does but NONE of the components show up. When I check source code this is what the component renders : but for some reason I can't see the component? This is my app.js file: /** * First we will load all

in laravel 8 with seeding , i has this issue Target class [TableSeeder] does not exist

余生颓废 提交于 2021-02-05 02:50:16
问题 Illuminate\Contracts\Container\BindingResolutionException Target class [Database\Seeders\CountriesTableSeeder] does not exist. at C:\......\blog\vendor\laravel\framework\src\Illuminate\Container\Container.php:811 807▕ 808▕ try { 809▕ $reflector = new ReflectionClass($concrete); 810▕ } catch (ReflectionException $e) { ➜ 811▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e); 812▕ } 813▕ 814▕ // If the type is not instantiable, the developer is attempting

in laravel 8 with seeding , i has this issue Target class [TableSeeder] does not exist

不打扰是莪最后的温柔 提交于 2021-02-05 02:50:09
问题 Illuminate\Contracts\Container\BindingResolutionException Target class [Database\Seeders\CountriesTableSeeder] does not exist. at C:\......\blog\vendor\laravel\framework\src\Illuminate\Container\Container.php:811 807▕ 808▕ try { 809▕ $reflector = new ReflectionClass($concrete); 810▕ } catch (ReflectionException $e) { ➜ 811▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e); 812▕ } 813▕ 814▕ // If the type is not instantiable, the developer is attempting