laravel-5.2

laravel orm : where condition on table -> related table -> related table

倾然丶 夕夏残阳落幕 提交于 2021-02-19 07:54:25
问题 so here is my database for a book store books : id ,title category : id, title book_category : id , book_id, category_id book_stock : id , book_id , quantity , price considering all the relations are defined in the model , i can query book_stock it goes something like this Stock::with('Book')->get(); but what if i want to get stock of a book in the category = 1 i can use use condition on book Stock::with('Book' , function($q){ $q->where(['title'=>'abc']); })->get(); but how can i filter

Laravel authenticated dynamic subdomain routing

这一生的挚爱 提交于 2021-02-19 04:42:43
问题 I'm trying to get authenticated subdomain routing working for some specific variable subdomains: app.example.com staging.app.example.com testing.app.example.com These should be guarded by the auth middleware. They all essentially reference app.example.com but for different environments. Everything that hits these domains should go to the guest routes: example.com staging.example.com testing.example.com This is what I've tried so far... Created this middleware to prevent the subdomain

How to configure NGINX for codeigniter and laravel on same domain

蹲街弑〆低调 提交于 2021-02-18 19:11:01
问题 I need to configure nginx for different location on same domain for two php frameworks. example.com/ - codeigniter (root /var/www/html/codeigniter) example.com/api - laravel 5.2 (root /var/www/html/laravel) here my examples, but they not work. server { listen 80; server_name example.com www.example.com; root /var/www/html/codeigniter; index index.php; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$;

How to configure NGINX for codeigniter and laravel on same domain

独自空忆成欢 提交于 2021-02-18 19:10:03
问题 I need to configure nginx for different location on same domain for two php frameworks. example.com/ - codeigniter (root /var/www/html/codeigniter) example.com/api - laravel 5.2 (root /var/www/html/laravel) here my examples, but they not work. server { listen 80; server_name example.com www.example.com; root /var/www/html/codeigniter; index index.php; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$;

Laravel sorting last record

落爺英雄遲暮 提交于 2021-02-16 15:34:34
问题 I'm bulding a forum. In the main page, I want to show the last reply for each forum. The hierarchy is this: forums hasMany('App\Topic') hasManyThrough('App\Topic', 'App\Repley') topics belongsTo('App\Forum') hasMany('App\Reply') replies belongsTo('App\Topic') I did this: $forum->replies()->orderBy('created_at', 'desc')->first() And it worked. But I want to sort by topics and replies. If I post new topic after the last reply, I want that show as the last reply. Update : I did this, and it work

Laravel route method DELETE not working

耗尽温柔 提交于 2021-02-11 06:52:09
问题 In my routes.php , when I have: Route::delete('page/{id}', function ($id) { return "deleting $id"; }); And I send a delete or get request using Postman, This throws a MethodNotAllowedHttpException . When I change routes.php : Route::get('page/{id}', function ($id) { return "deleting $id"; }); It responds the string deleting... in response to GET , DELETE and PUT ! But the HTTP code is 403. It just throws a MethodNotAllowedHttpException on a POST request. This problem seems to occur only on

Converting an array of arrays from Laravel's collection into an object with an array in json

空扰寡人 提交于 2021-02-10 12:07:58
问题 I am generating an an array of categories and subcategories in my Laravel API for use in my client side app. I'm doing this by using the collection's filter and map methods to organize the data pulled from the database: // get the data from the category table $categoryData = $categories->all()->categories(); // filter the data by category names we know we want and create the multi-dimensional array of the fields we need $categoryList = $categoryData->filter(function ($value) { return $value[

Converting an array of arrays from Laravel's collection into an object with an array in json

眉间皱痕 提交于 2021-02-10 12:07:55
问题 I am generating an an array of categories and subcategories in my Laravel API for use in my client side app. I'm doing this by using the collection's filter and map methods to organize the data pulled from the database: // get the data from the category table $categoryData = $categories->all()->categories(); // filter the data by category names we know we want and create the multi-dimensional array of the fields we need $categoryList = $categoryData->filter(function ($value) { return $value[

Converting an array of arrays from Laravel's collection into an object with an array in json

左心房为你撑大大i 提交于 2021-02-10 12:06:42
问题 I am generating an an array of categories and subcategories in my Laravel API for use in my client side app. I'm doing this by using the collection's filter and map methods to organize the data pulled from the database: // get the data from the category table $categoryData = $categories->all()->categories(); // filter the data by category names we know we want and create the multi-dimensional array of the fields we need $categoryList = $categoryData->filter(function ($value) { return $value[

Auth guard driver [api] is not defined?

两盒软妹~` 提交于 2021-02-09 11:06:15
问题 I use this library jwt-auth-guard in Laravel 5.3. When I try open page I get error: InvalidArgumentException in AuthManager.php line 99: Auth guard driver [api] is not defined. How can I fix it? I made everything that was need 回答1: I'm not sure, please check you guard driver setup into config/auth.php first. You can cross check this from GIT repo. Let me know if any concern from above. 回答2: If you are using tymondesigns/jwt-auth package first check that you are downloading the latest version