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
1 answer

convert mysql to query to laravel query

Hello i am trying to convert this mysql query to laravel query but still i have no success. can you please help to convert this mysql query to laravel query. Mysql query as below select *,SUM(pp.starting_balance) as total from (select `aa`.*,…
Code Embassy
  • 247
  • 2
  • 16
-1
votes
2 answers

How to write this query using Laravel query builder?

I'm new to laravel. Here is my query that filters out the quizes that don't have any problem (questions) or the problems don't have any answers. but I'm not sure how to write it properly using laravel query builder. Considering I'm using eloquent to…
Nooglers BIT
  • 71
  • 2
  • 11
-1
votes
2 answers

How to call sp with named parameters without any order in laravel

I have one sp for inserting the data, it has three params, Ex: a,b,c. so I want to run the sp with params, but not able to find the solution in laravel. This is what i tried. DB::select('EXEC sp_name @a=a, @b=b, @c=c'); But, its not working.
Vikash
  • 3,391
  • 2
  • 23
  • 39
-1
votes
1 answer

Conditional search in laravel

Issue: When I search in my posts I get result from posts and products both, but when I search in products I only get results from products (which is correct) codes my controller: public function search(Request $request) { $search =…
mafortis
  • 6,750
  • 23
  • 130
  • 288
-1
votes
1 answer

Laravel eloquent and query builder Eager Loading Multiple Relationships with where clause

I have few tables, they are room_types, rooms, rates, prices I want to get room_types with rooms with rates and rates with prices where(price room_type_id = room_types.id) . I tried to do something like that $roomTypeIds = []; …
David
  • 111
  • 2
  • 13
-1
votes
1 answer

Stack in the WhereRaw clause in the following Code

How whereRaw works here? If it just plain SQL?
Abhijit Mondal Abhi
  • 1,364
  • 4
  • 15
  • 34
-1
votes
1 answer

Get any of the item from the Array with whereIn in Laravel 5.3

I'm using laravel 5.3 and trying to build a query with multiple where and wherein function. Here is my code: $posts_id = "1,3,4"; //from my query $results = Post::select('*'); $results->whereIn('posts_id', [$posts_id]); $resutls->get(); There…
-1
votes
2 answers

Laravel query doesn't want to select last one

I tried distinct before but somehow my query won't select the last comment. He always select the oldest comment. Then i tried it with groupBy instead of distinct. But this won't work either. My current…
Smokegun
  • 81
  • 2
  • 14
-1
votes
2 answers

How to convert mySQL Query to Laravel 5.4 Query Builder

Please someone should help me convert this SQL Query to Laravel 5.4 Query Builder syntax. I have searched for solutions and found some but not exactly as I wanted. I have 3 tables: Feeds: - feed_id - user_id - feed_title Users: - id -…
-1
votes
1 answer

how to use find count using raw method in query builder on laravel

I am trying to find count of gender using the raw statement but i get this error Parse error: syntax error, unexpected '$total' (T_VARIABLE). Can someone please tell me whats my error $collection='{gender:"Male"}' $total =…
-1
votes
1 answer

How to convert SQL into Laravel 5.2 Query Builder

Hello I am very new to Laravel and am having a big problem converting the following MYSQL query into a Laravel Query Builder. I am using Laravel 5.2. Here is the working MYSQL query: select * from (select b.id, SUM(v.value) as total from…
GustavMahler
  • 657
  • 1
  • 6
  • 23
-1
votes
1 answer

Is it possible to get values of two different columns and different rows in a single record using Laravel query builder?

So I am trying to get values of two different columns and different rows in a single record. I have one table ticket_thread with following columns id ticket_id is foreign key referenced to ticket table and it helps to get all the conversation…
Manish Verma
  • 469
  • 7
  • 17
-1
votes
1 answer

Specifying where-and in Laravel's query builder

I have the following code which works: $name = 'jhon'; $users = DB::table('account')->where('login', '=', $name)->get(); How would I specify the AND parameter so that I can query on multiple conditions? $login = $request->login; $password =…
indian
  • 75
  • 1
  • 1
  • 5
-2
votes
1 answer

How to add custom method to Laravel Query Builder

I want to add custom methods for Laravel Query Builder. I want to have something like this (Methods will be more complicated in further)
Kostya GL
  • 62
  • 6
-2
votes
1 answer

Where Equals Subquery Laravel

How can I convert the following SQL query to Laravel: SELECT * FROM SomeTable WHERE some_column = ( SELECT some_column FROM SomeTable st1 where st1.some_column2 = SomeTable.some_column2 ) This query is just an example query. I know…
1 2 3
99
100