Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 9 months ago. Improve this question I tr…
Tag: laravel
Getting rank of row in OrderBy desc Eloquent query, How can i make this query work in laravel 5.5 eloquents?)
I am trying to give my users a ranking number for my Laravel hiscores pagination table. This is the MySQL query I found working. I am trying to put make this work as a Laravel eloquent query. My Laravel eloquent query right now: Answer This is my solution. I first added this function to my User Modal Class. N…
Display images with VueJS and Laravel
I am trying to display images with VueJS, but it either prints {{ activity.image }} or shows a compilation error. These are the attempts: How do I do it? Answer I assume activity.image is coming from the JavaScript, since you’re using the dot notation. You can use v-bind:src=”activity.image”…
How to mock properly IlluminateHttpRequest class from Laravel
I’m trying to test a method from a class which contains a method using the request() helper from Laravel. This is the method: Category class The test should make this helper to catch properly the URI when doing getRequestUri() but it’s actually returning an empty string. This is one of the thousan…
SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘payments’ already exists (SQL: create table `payments`
When I migrate a table I see this error, SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘payments’ already exists (SQL: create table payments Error Answer If you want to recreate the table, run php migrate:rollback first to delete the existing one. This command will run the down() …
Sufficient API Response for Mobile App
I’m creating an API for my mobile app with Laravel – Lumen and i have the following scenario which i don’t know what is the most sufficient way to return the response to my Android / IOS App, lets assume that the user is trying to sign in (same end point): Case 1 : the user provide the corre…
set base URL dynamicaly in Laravel 5
I have two versions of a site one running at on example.com and other at example.com/version2. In web.php I have In webconfig middleware I set database connection for version2 site. Which is working fine but I am also setting base URL for version2 site. which not working url() method returns example.com Here …
Laravel: How to use the ignore rule in Form Request Validation
Laravel has a ‘unique’ rule with an ‘except’ clause. From the validation documentation, it takes this form: My application has a ‘shop’ entity. When the user updates the shop’s profile, I have a Form Request, with a validation rule configured as follows: (The primary …
Proper syntax for Guzzlehttp request containing body and header
I have the following Guzzle send request on my controller :- The above syntax only sending the header but , what is the proper syntax i should use to send both header and body. Answer Guzzle docs has plenty of examples, try reading them.
Laravel Cannot delete or update a parent row: a foreign key constraint fails
For some reason a user cannot delete a post if it has been liked, it was working before but when I linked posts with likes I have been getting this error, I can’t even delete it in Sequel Pro, unless I delete the likes associated with the post first. Error SQLSTATE[23000]: Integrity constraint violation…