Laravel – DB::TABLE SQL – how to get join data in one queries

I Have 2 tables first client_group with data like below second table client in Controller I have code like below: $client = DB::table(‘client_group’) ->where(‘client_group.user_id’…

User with multiple companies (different type)

I built an application in Laravel that is a simple CRUD app. Now im struggling with migrations a bit. User belongs to Company. Company can have many users. Company type can be Supplier, Customer or …

Laravel binding parameter using insert() with convert() inside

I am having a hard time binding my SQL query and I only have a few braincells left. Basically, this code works but prone to SQL injection: return DB::connection(‘sqlsrv_rfo_user’) ->table(‘dbo….

Laravel : convert grouped data to one row

Hello please i want to convert grouped data with duplicated keys and different values to one row. For example : “book1” { { “id” : “1”, “group” : “book1”, “name” : “…

How do where one to three values ​come from the combo box in Eloquent Laravel?

I have a filter with three check boxes, each of which has a Value “question”, “partnership”, “complaint”. but when I select two data from the check box (ex.complaint & question) sent to the …

Cannot use object of type IlluminateDatabaseQueryBuilder as array

I cannot find the error here how do i fix this? $db2 = DB::connection(‘sqlsrv’)->table(‘Checkinout’) ->join(‘Z_MemRecord’,’Checkinout.Userid’,’=’,’Z_MemRecord.uid’) ->select(DB::raw(“…

SQL Query, or Eloquent Query a foreach loop

I have a question. Say I have two collections; CompanyOrders and User and need to do a loop to fetch all users involved in company orders, how would i do that? The example of a query that i am looking …

Using raw DB to query but fails to run because sql string has an error

Im new to using laravel and i have to query using the an sql string but the code fails to run because there is an error in the sql query The code is: $current_lat = $request->latitude; $…

Laravel skip results if they are found in previous query

I’m querying my DB twice to get some items into the header of the page and some bellow the header. I want to avoid duplicates in these two queries, currently I do this by adding a skip method to …

How to make this type of query in Laravel?

This is the sql query but how can I do it in laravel? SELECT id FROM clientes where email is null and phone is null and id in(SELECT DISTINCT(cliente_id) FROM reservas WHERE dia < now()) This is …