app/Http/Controllers/DiscountsController.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()
    {
        if(auth()->user()->isClient()){
            $discounts = Discount::where('user_id', auth()->user()->id)->orderBy('discount', 'desc')->get();
            foreach($discounts as $discount){
                $discount->subcategory = $discount->getSubcategory();
            }
            return view('pages.discounts.index')->with('discounts', $discounts);
        }
    }
public function index ( ) { if ( auth ( ) -> user ( ) -> isClient ( ) ) { $ discounts = Discount :: where ( 'user_id' , auth ( ) -> user ( ) -> id ) -> orderBy ( 'discount' , 'desc' ) -> get ( ) ; foreach ( $ discounts as $ discount ) { $ discount -> subcategory = $ discount -> getSubcategory ( ) ; } return view ( 'pages.discounts.index' ) -> with ( 'discounts' , $ discounts ) ; } }
Display a listing of the resource.
Display a listing of the resource .