Skip to content

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…

Will my query works without two dimension array in if else or not

I have confusion since I was looking inside and try to solve the problem. I have PHP application which is running in Oracle DB and so far some expression is written in MySQL and right now I want to migrate those query to Oracle SQL function and call function insted of writing query directly to model. The situ…

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…

Can Microsoft’s SQLSRV driver for PHP run on Apache?

Scenario: I have a PHP website running on Apache server I have an ERP system (MS SQL) that runs on a different server I need to connect from my website to that MS SQL server I need to work with Microsoft SQL Server in my PHP application. I’ve managed to get their SQLSRV driver for PHP running on my loca…

PSR-12 and assigning same value to multiple variables

Is it allowed to assign multiple variables on the same line in PSR-12? For example: Answer Yes. If it’s not explicitly stated, then there is no standard. Either works. Also, chain assignment like that just makes the code cleaner so I personally would not see a reason to why it should not be allowed. htt…

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…