Skip to content

Tag: laravel

Left Join – In Eloquent

I would like to connect user table and like table based on the user_id So I have this Model user.php like.php and my query I would like to return the ‘likes’ table inside the ‘user’ but it doesnt work. I would like to left join it. What am I doing wrong? Answer Well, you need to use on…

Queries in Laravel – Equivalent to left join

Currently this is my laravel query But unfortunately, I would also like to get the connected data between the company and the user table, user_id for company and id for user this is the table company table: and the user table How to I connect the user under the company array? Answer You need to make a relatio…

Array variable inside DB::raw query laravel

I want to predifine $processingStatus array and use it inside Laravel DB::raw query but this gives me the following error- Syntax error or access violation: 1064 You have an error in your SQL syntax My query is a large one so I am only pasting the fragment which I guess is causing the error- DB::raw(“CO…

Laravel Query Builder joining with alias

I have two tables Unknown table Clients table My Code : Joining will be with the clients.id => unknown.parent_id… As because the clients table has a parent_id that’s why i have to use the alias Please Help me to do so! Answer Using Alias Working Solution: