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’…

exists query does not return relevant result

I have a Laravel application with this Eloquent query: $products = Product::where(‘name’, ‘LIKE’, “%{$value}%”) ->whereHas(‘categories’, function($q) { $q->where( ‘slug’, ‘…

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” : “…

left join and return only the latest record from right table using LARAVEL 6.5.0

Table 1 ———- NameID Name —————— 1 A 2 B 3 C —————– Table 2 ——————– ID NameID Order ——————– 1 1 …

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; $…