I know this question is not asked in a well manner way,so I am sorry,I have SQL query this one I want to convert it in PHP laravel query form so tried this query but I don’t know SQL and even I am not understanding how I convert it, can someone help just convert SQL query to laravel query? here
Tag: laravel-5
Laravel/MariaDB: errno 150 “Foreign key constraint is incorrectly formed”
I’m on Laravel 5.4, PHP 5.6, Ubuntu 18.04, MariaDB 10.4.8. When I run php artisan migrate, I get: I’m trying to use https://github.com/klisl/laravel-comments. Before trying to perform a migration with this package I had created DB at phpMyAdmin, had configured .env by adding DB name and stuff, had successfully run php artisan migrate, php artisan make:auth and php artisan make:controller
How to always fetch a special category item data first in Laravel
Suppose I have a table named machine with 3 columns(id, name, company). There are 5 data in that table. Here A,B,C,D,E are the machine name and XX,XY,YY are the company name. Now I want to fetch data according to company wise and there a specific company’s data will come always first. For that I use groupBy with company. SQL Result
Laravel Eloquent Join Using Another table
Hi how to convert this SQL query to Laravel Eloquent? I have three table: payments, devices and users. Payments table does not store user_id. but table has device_id. And device table also has user_id. I want to get user name which made payment. Answer it’s very easy Another way is: We have three models: User (has many devices) Device(belongs to
How do I catch a query exception in laravel to see if it fails?
All I’m trying to do is verify a query. Without that erroring out, I’d like to know it failed so I can return a response that states “Error: table does not exist” or the generic error. Answer The simplest way to catch any sql syntax or query errors is to catch an IlluminateDatabaseQueryException after providing closure to your query: If