In my laravel project I have tables shown as below. groups and users are in Many-to-Many relationship, which mean that a user can belongs to multiple groups. The group_user table is intermediate table which represents which user belongs to which group. slot_votes table records users’ vote on slot. Relationship of it with groups table is ..
Help, I want to convert this SQL query to Query builder Laravel DB::select(‘SELECT * FROM (SELECT RANK() OVER (ORDER BY nombre ASC) ranking, studios.* FROM studios) studio ORDER BY ranking’); It works on the local server using DB::statement("SET SQL_MODE=”"); But on the Hosting server it does not work. Sourc..
$loantype = $request[‘regloan_type’]; $loans = Loan::select(‘date_release’) ->where(‘invalid’,false) ->where(‘transaction_year’, $transyear) ->where(‘loan_type’, $loantype) ->get(); If variable $loantype returns null then I want to select all the record in that column. How to do that in laravel where clause? I have used if else statement to get what I want. But is there a way I can do ..
Suppose if I have a table of ID Col1 Col2 Col3 Col4 Col5 1 Hello "" Hi "" "" 2 two "" Hi here "" I want to get the count of Col(X) without including the empty column. So for record 1 I must have a count of 2 and for record 2 I have ..
I’m going to convert this Eloquent query to DB query in Laravel. $users = User::withCount("addresses", "cars")->get(); The above one is Eloquent and it’s working well. But I’d like to do this with DB query. I tried to do as following but I couldn’t get expected result. $users = DB::table("users")->join("addresses", "users.id", "=", "addresses.user_id") ->join("cars", "users.id", "=", ..
I’m trying to get last month order items report. Here is my table structure orders id – integer amonut- double order_items (pivot table) id – integer order_id – foreign item_id – foreign quantity price I want to get last month’s order items quantity and total price respectively. Like this Item A – 20 qty – ..
Im trying to create a laravel project using laravel new proj_name but it shows always showing that composer is not recognized as an internal or external command operable program or batch file i have set my environmental variable as C:UsersadminAppDataRoamingComposervendorbin; and my pathext as .PHAR; dont where i made the mistake, it works perfectly with ..
This is a long post, sorry in advance. I have a couple of questions regarding the diagram below. How do I create a relationship for these tables? (tried "belongsToMany" and "hasMany") Should I use Eloquent or Query Builder to get desired result? (image is attached below for desired result) Is "client_order_items" a pivot table? How ..
Here is the MySQL query. I’m facing a problem converting it in laravel DB syntax. select super_consumers.id , super_consumers.name, ifNull(tot_balance_amount , 0) as tot_balance_amount, ifNull(tot_recharge_amount, 0) as tot_recharge_amount from super_consumers left join (select super_consumer_id,sum(amount) as tot_balance_amount from balance_ins where type=’1′ group by super_consumer_id ) as a on super_consumers.id=a.super_consumer_id left join ( select super_consumer_id,sum(amount) as tot_recharge_amount ..
I just want to know, can I create ‘eloquent relationship’ using query builder on Laravel. Is there a way to do that? Example: I have two table users ======== user_id user_name events ======== event_id event_name user_id I know that if I want to select event and want to show the user who create the event ..