Skip to content
Advertisement

Tag: laravel-5

How to convert SQL query in laravel query?

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

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

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

Advertisement