mouzak
324
1
Laravel

laravel selectRaw

Posted 4 months ago by mouzak

hello i need help please, i add several columns. the result is good, but if one of the columns is null, the query does not return a result. How to solve this problem. Thank you.

public function B_paie( Request $request) { $data=array();

    $data['paies' ]= DB::table('salaries')
            ->leftJoin( 'paie','salaries.id', '=', 'paie.idsalaries')
            ->leftJoin( 'primes','salaries.id', '=', 'primes.idsalaries')
            ->select('salaries.*', 'paie.*','primes.*')
        ->selectRaw('(salairebase + sursalaire + primetransport + congepaye + autreprimes) as total')
            ->where('salaries.id', $request->id)
           return view('bulletin_paie',compact("data"));

}

Please sign in or create an account to participate in this conversation.