Questions tagged [laravel-query-builder]

The database query builder provides a convenient, fluent interface to creating and running database queries in Laravel apps. It can be used to perform most database operations in your application, and works on all supported database systems.

1522 questions
-1
votes
3 answers

db::raw adding is null in query

I am trying to use laravel query builder like:- $users = DB::table('baid_collection') ->select(DB::raw('sum(total) as total_collect,collection_limit_c')) ->join('users_cstm', 'baid_collections.assigned_user_id', '=',…
Vivek Modi
  • 31
  • 1
  • 9
-1
votes
2 answers

how to get data from two table which has no relationship

I have the following tables: patient_medicines (id, drugname, strength, state, quantity, active, patient_id) medicine_products (id, prod_name, prod_generic, prod_state, prod_strength, prod_company, batchno, rate, quantity, prod_expired) stocks…
-1
votes
1 answer

How to get all users with all their roles in a many to many relation based sql query?

Goal Get all users with all their roles. Problem If one user has more than one role, i get an instance of this user for each role he has. Description I have a setup with three tables, like it is described in this stackoverflow post for example. A…
leonp5
  • 305
  • 7
  • 23
-1
votes
1 answer

how to count in laravel collection?

this is collection i get: 1 => App\Match_fact {#1332 ▼ #guarded: array:2 [▶] #connection: "mysql" #table: "match_facts" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] …
-1
votes
1 answer

Laravel query - whereIn orWhere combined

I have a collection Products and productVendors: ["ASICS TIGER","FLEX FIT"] productTypes: ["SHOES","T-SHIRTS"] productTags: ["autumn","cap"] I can easily write: $products->whereIn('productVendors', ["ASICS TIGER","FLEX FIT"]) …
Aleks Per
  • 1,549
  • 7
  • 33
  • 68
-1
votes
1 answer

Why I i got different result in laravel query builder

So i tried to convert this sql query to laravel query builder select jenis_data.id_jenisdata, jenis_data.id_level, jenis_data.nama_data, detail_A.id_kecamatan, satuan.satuan, detail_A.tahun, detail_A.angka as tahun_2018, detail_B.angka as…
Qori H
  • 1
  • 1
-1
votes
2 answers

Laravel Query Builder / How to stop it from adding square [brackets]?

Im trying to get laravel 7x to work with impala/kudu provided by cloudera. Ive got the ODBC connection which connects fine and if you run raw sql query it also works fine. Database connection entry: 'impala_connect' => [ 'driver' => 'sqlsrv', …
Raheel Hasan
  • 5,753
  • 4
  • 39
  • 70
-1
votes
1 answer

Query builder with multiselect data

I've a multiselect in a form which return an array (method=get). In the DB I've the relative field (varchar) with stored something like: ["apple","lemon","banana"] How to search in the DB with query builder to check if array values returned from…
natas
  • 456
  • 2
  • 9
  • 15
-1
votes
1 answer

MAATWEBSITE LARAVEL

I want to import data tables(multiple) using excel(single) file. I am not sure how to achieve same with query builder. I am not using model for this. Excel::import(QUERY BUILDER INSERT QUERY, $request->file('file')->store('temp')); can i use insert…
-1
votes
1 answer

Combine two group by queries with query builder

I have two similar groupBy queries this: DB::table('orders') ->join('users', 'orders.user_id', '=', 'users.id') ->groupBy('users.sponsor_id') ->selectRaw('users.sponsor_id, sum(points) as total_points_a') …
Adam
  • 25,960
  • 22
  • 158
  • 247
-1
votes
1 answer

How can I show and pagination two queries in the laravel blade?

I want to show $personnals and $users in a table in the blade. I know, I have to use @foreach. But I can't. Because, I have two queries and I can't pagination and show those. $personnals = DB::table('orders') ->where('pay_type', 1) …
-1
votes
1 answer

select a row for each column`s value

I have got a condition and i want to use mysql temporary tables. i have Tasks table and Jobs table. tasks has one to many relation with jobs (each task has one or more jobs) i want to select The Last Job of each task in a query (based on created_at…
Abilogos
  • 4,777
  • 2
  • 19
  • 39
-1
votes
5 answers

How insert a query into a database using Laravel?

I have this query $data = DB::table('incidencias') ->join('clientes_incid', 'clientes_incid.rif', '=', 'incidencias.rif') ->select('incidencias.rif') ->distinct() ->get(); And I want to insert the information of this query in a new…
-1
votes
3 answers

Laravel eloquent, get 500 error with just a get()

Here the code : $search = request()->get('search'); $conciergerieSelect = request()->get('conciergerie'); $services = Service::get(); $available = 'Disponible'; $prestations = Prestation::with([ 'service:name' ]) …
Tony S
  • 491
  • 6
  • 26
-1
votes
1 answer

Laravel 5.7 | Passing data / variables used in a first function to build the view to a second function to generate a dompdf file

Important : I didn't get my data from a model, but from a Query Builder query. The following first function build a view based on the user search criteria and filtered the data accordingly : public function updateOrderList(Request $request) { …
marcq
  • 477
  • 3
  • 12