lundi 24 mai 2021

Laravel group by id, sum qty and group date to month and year request only and get count

I want to make data based on 2 groups. namely the month group in that year and the group id then calculated based on the existing product id of the product in

I tried this code

$tahunx = '2021';        
          $barangmasuk=BarangMasuk::groupBy('id_barang','months')->select([
                'barang_masuk.id_barang',
                DB::raw("DATE_FORMAT(tgl_masuk,'%M %Y') as months", '=',$tahunx),
                DB::raw('sum(jml_bm) as jumlah')
            ])->get();
    
            dd($barangmasuk);

I want to create data that looks like this

enter image description here

there is table 1 and table 2 that I use

Please help



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3vkphbx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire