app/Http/Controllers/DebtorController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
       $debtor=Debtor::where('user_id', auth()->user()->id)->orderBy('created_at', 'asc')->get();
       $temp=0;
       foreach($debtor as $debt)
       {
           $temp+=$debt->money;
       }
      $grupy=Debtor::where('user_id', auth()->user()->id)->GroupBy('name')->orderBy('name')->selectRaw('sum(money) as Suma')->get();
       $whos= Debtor::where('user_id', auth()->user()->id)->selectRaw('DISTINCT(name)')->orderBy('name')->get('name');
        return view('debtor', [
            'debtor' => $debtor,
             'allmoney' => $temp, 
             'grupy' => $grupy,
             'whos' => $whos
                ]);
    }
public function index ( ) { $ debtor = Debtor :: where ( 'user_id' , auth ( ) -> user ( ) -> id ) -> orderBy ( 'created_at' , 'asc' ) -> get ( ) ; $ temp = 0 ; foreach ( $ debtor as $ debt ) { $ temp += $ debt -> money ; } $ grupy = Debtor :: where ( 'user_id' , auth ( ) -> user ( ) -> id ) -> GroupBy ( 'name' ) -> orderBy ( 'name' ) -> selectRaw ( 'sum(money) as Suma' ) -> get ( ) ; $ whos = Debtor :: where ( 'user_id' , auth ( ) -> user ( ) -> id ) -> selectRaw ( 'DISTINCT(name)' ) -> orderBy ( 'name' ) -> get ( 'name' ) ; return view ( 'debtor' , [ 'debtor' => $ debtor , 'allmoney' => $ temp , 'grupy' => $ grupy , 'whos' => $ whos ] ) ; }
Display a listing of the resource.
Display a listing of the resource .
//       $debtor= Debtor::orderBy('created_at', 'asc')->get(); //$howmuchs= Debtor::where('user_id', auth()->user()->id)->distinct('name')->count('name');