The tables in my active DB are empty after tests. I have the test environment variable DB_CONNECTION=mysql_testing. When I run my tests and do dd(env(‘DB_CONNECTION’)) – everything is fine. I see ‘mysql_testing’. But when I write dd( DB::connection()->getDatabaseName()) I see …
Tag: laravel
How to validate a unique field on a record update
I am recently started a laravel project to control some activities, but I am currently having issues with the validation specifically when updating a specific record on a table that contains unique values A couple of notes a started this project a couple of days of the launch of laravel 8 last month so perhap…
json rpc 2.0 in laravel api errors on add request
I add https://github.com/sajya/server for making json rpc over my laravel 8. I just follow the instructions provided here to test it https://sajya.github.io/docs/ All works for the basic example, But if I add params to the curl string an error is raised an error that i cannot understand: my code: my route api…
PHP looping over data and getting key/value pairs
I’m using Laravel 8 to loop over some data. I’ve got my data out from my database, but am struggling to loop over the data in a foreach loop, it doesn’t appear to be giving me the key/value pairs, only the index/value pair? But if I var_dump() my $applicationOptions I can see the array insid…
get a deeper element which satisfies the condition
Need to get the postal_code value, which is the value of long_name with types=postal_code. In the api result,it seems types itself is an array. Looping and finding out is a bad method. also array_search also don’t work. Can anybody help me. Answer Just loop through the array and find an item with the po…
Submit Laravel form using JavaScript
I have an HTML form that I currently submit using the form action attribute and a php script. The post request is successful, but it reloads the page, and I want to avoid that. The project uses Laravel/Blade PHP templates. To prevent page from reloading, I would like to send the post request using JavaScript …
Problem with displaying pictures in laravel 7
i’m working on Laravel 7 , i want to display the images added by the administrator, but they don’t show up. This is the index.blade.php : This is the adress of the pictures : C:wamp64wwwProjectclientstorageapppublicproductSeptember2020 Thanks fo help Answer First create a symbolic link : Then a sy…
updating blade view everytime theres an update in the the database table
I have a stat bar on my blade, which for example says ‘Calls Today : 0’ etc, I need for the the stats to update each time theres an update in the sql database for calls today. so for example if calls Today goes up to 5 in the database, the blade views Calls Today must also go up to
how to apply pagination in this case using laravel 6
i got the annonces from a user authenticator, and i want to do pagination but i don’t know how. UsersController.php Answer
Binding Interfaces to Implementations in Eloquent relationships
According to “binding-interfaces-to-implementations” it is possible to bind an interface with its implementation, as follows: So when I call the next line, I will get an User object: ???????? However… when I try to do the same process with an Eloquent relationship: it, obviously, gives me th…