Hi I am new to Laravel and I and trying to create a relationship bewteen my posts and post comments. I want to show all comments on a post with the same post_id as the posts id. I think it should …
Tag: laravel
Two models for one Controller in Laravel (methods Edit & Update)
Would you please let me know if this controller SerieController is correct? As I don’t think so. There are two models in fact. One Model is Serie and the other is Mark. When, I click on the drop down list, I don’t see my items… My edit.blade.php Concerning the model Model Serie Model Mark Th…
Laravel download pdf returning random characters
Im trying to download my earlier saved pdf. Ive created this function. And it returns this: Var dumping my $filepath is resulting in this : C:laragonwwwYTBNstorage/pdf/billing/invoice/YTBN_Armando_3_2019-0305.pdf” Which is correct. Answer try to used like that or u can used directly in laravel 5.5 file …
Use a boolean function to determine the results in Laravel query builder
I have shops that open at a specific time and close at a specific time and I want to filter these stores according to a time period specified by the user so that all the returned shops will be …
The Mix manifest does not exist when using orchestral/testbench
Creating a custom Laravel package using the orchestral/testbench package that helps package developer to help with PHPUnit test. So, my package on a different place and not in a Laravel installation exactly. Everything works great except the mix() function that I’m using on the blade view for resources.…
fetch related records between 3 model
I have few products in 3 category (for example), and each product has a brand. I want to show brands which related to products in a specific category. Models: –product –brand –category relations: category has many products brand has many products How can I do that? Answer Considering you hav…
My custom message Request validator not work Laravel
I use the Request validation but I don’t get message from request. Look my code and see my mistake. Only important is store function which work good if all fields is fullfiled but if any field not …
Sort Laravel Collection by custom order, other than asc or desc
I have this array as Laravel Collection : And I need to sort it by status, not by asc or desc, but the records with status 2 should be first on the list, then status 1 then status 3. I can’t figure out how to achive this, thank you in advance. Answer Hi had similar issue, [‘2’, ‘1̵…
Laravel paginate pivot tables
I have collections which contains custom products I need to paginate those collections products but I receive error. data With this query I can get my collection and it’s products but I’m not able to paginate products. $collection = Collection::where(‘slug’, $slug)->where(‘sta…
PHP Laravel – Eloquent is returning boolean fields randomly sometimes as 0 1 and others as true false when calling the method json
I am using Laravel Eloquent to write a REST API. When calling json from response() to return the object, boolean fields are returned as 0/1 sometimes and as false/true others. I would like to unify the format and make it all as 0,1 or as false,true instead of it being random here is the code sample: this retu…