Category : laravel-query-builder

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 ..

Read more

$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 ..

Read more

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", "=", ..

Read more

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 ..

Read more

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 ..

Read more