Laravel 8 DB::raw Database



 $model = DB::table('flight')
    ->select(
        DB::raw("SUM(CASE WHEN status <> 'active' AND date <> '' AND  date < CURRENT_DATE :: TEXT THEN 1 ELSE 0 END ) AS active_count"),
        DB::raw("SUM(CASE WHEN status = 'deactive' THEN 1 ELSE 0 END) AS deactive_count")
    )
    ->where(['delete_flg' => '0'])
    ->whereRaw("payment_status != 'Payment'" )
    ->whereRaw("CASE WHEN ".(RoleUtil::isOwner($roleId) ? 1 : 0)." = 1 THEN created_by = ".$userId. "
                    WHEN ".(RoleUtil::isHeadOfficeAdmin($roleId) ? 1 : 0)." = 1 THEN 1 = 1 END ")
    ->first();
Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment