Skip to content

Tag: laravel

How to assert paginations in Laravel?

I have a category model with the following method: My category controller: This is what I’ve tried, I am using RefreshDatabase trait. This test fails for some reason: Answer The reason you get this error is because somehow the posts are eager loaded from the view/controller but not from the tests. I&#82…

Parsing Request, PHP/Laravel

This API is used by an access control device to report personnel pass-through records, After me (A third-party platform) called the API to a face recognition terminal or face recognition access control terminal. Calling direction: A face recognition terminal or face recognition access control terminal calls t…

PHP how to use OR in the right way

I have simple part of code to detect type of Discount, i added another type, but how to use operator OR (||) right way in this case ? ->where(‘taken’, “N”) or “R” do something. this wont work ->where(‘taken’, “N” || “R”) Answer in t…

Multiline Eloquent query

I’m trying to filter my products based on selected filters and possibly a search term/word. My filters have a relationship with categories, which in their turn have a relation ship with my products. My code below only works (without the if statement checking for a search term/word) when everything is ch…

Access File Uploaded Attributes in Laravel 5

I upload a file In my controller, I did this I see this I want to pathname: “/private/var/tmp/phpb73hcy”, I’ve tried I just want this /private/var/tmp/phpb73hcy Any hints for me ? Answer Use $this->getPathname(). The Laravel UploadedFile class extends the Symfony UploadedFile class, which…