mardi 10 mai 2016

SUM table in laravel 5

here my table and what i want to do

SUM data column total ?for example i have two data in column total 01:45 and 02:25 result must be 4:10 . i have already try but my code only sum the hours not with the minute. what should do ?

here my controller. for sum

public function getMei()
    {
        $data['users'] = DB::table('lembur_karyawan')
                ->select('nama', DB::raw('SUM(total) as total_lembur'))
                ->groupBy('nama')
                ->havingRaw('SUM(total)')
                ->first();

        return view('mei_user', $data);
    }

and my view :

<?php echo $users->{'total_lembur'} ?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire