app/Http/Controllers/retailerController.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()
    {
        $user_id = Auth::user()->id;
        $reviewItems = DB::table('feedback')->where('feedbackType', '=', "review")
            ->join('orderItem', 'feedback.orderItem_id', '=', 'orderItem.id')->join('users', 'feedback.user_id', '=', 'users.id')->get();
        foreach ($reviewItems as $key => $reviewItem) {
            $spare = Spares::find($reviewItem->spare_id);
            if ($spare->retailer_id != $user_id) {
                unset($reviewItems[$key]);
            } else {
                $reviewItems[$key]->spdescription = $spare->description;
                $reviewItems[$key]->imagePath = $spare->imagePath;
            }
        }
        $orders = App\Orders::all();
        $reviewCount = $reviewItems->count();
        $enquiryCount = App\Enquiries::all()->count();
        $orderItems = Orderitem::with('spare', 'order')->where('orderStatus', '=', 'purchased')->get();
        foreach ($orderItems as $key => $orderItem) {
            if ($orderItem->spare->retailer_id != Auth::user()->id) {
                unset($orderItems[$key]);
            }
        }
        $ordersCount = $orderItems->count();
        $orderItems = Orderitem::with('spare', 'order')->where('orderStatus', '=', 'purchased')->orderBy('created_at', 'desc')->get();
         foreach ($orderItems as $key => $orderItem) {
            if ($orderItem->spare->retailer_id != Auth::user()->id ) {
                unset($orderItems[$key]);
            }
        }
        $a=0;
        foreach ($orderItems as $key=>$orderItem){
            if($a>=10){
                unset($orderItems[$key]);
            }
            else{
                $a=$a+1;
            }
        }
        $complainItems = DB::table('feedback')->where('feedbackType', '=', "Complain")
            ->join('orderItem', 'feedback.orderItem_id', '=', 'orderItem.id')->join('users', 'feedback.user_id', '=', 'users.id')->get();
        foreach ($complainItems as $key => $complainItem) {
            $spare = Spares::find($complainItem->spare_id);
            if ($spare->retailer_id != $user_id) {
                unset($complainItems[$key]);
            } else {
                $complainItems[$key]->spdescription = $spare->description;
                $complainItems[$key]->imagePath = $spare->imagePath;
            }
        }
        $complainCount = $complainItems->count();
        return View::make('Retailer/home')->with('reviewCount', $reviewCount)->with('enquiryCount', $enquiryCount)->with('ordersCount', $ordersCount)->with('complainCount', $complainCount)->with('orders', $orders)->with('orderItems', $orderItems);
    }
public function index ( ) { $ user_id = Auth :: user ( ) -> id ; $ reviewItems = DB :: table ( 'feedback' ) -> where ( 'feedbackType' , '=' , " review " ) -> join ( 'orderItem' , 'feedback.orderItem_id' , '=' , 'orderItem.id' ) -> join ( 'users' , 'feedback.user_id' , '=' , 'users.id' ) -> get ( ) ; foreach ( $ reviewItems as $ key => $ reviewItem ) { $ spare = Spares :: find ( $ reviewItem -> spare_id ) ; if ( $ spare -> retailer_id != $ user_id ) { unset ( $ reviewItems [ $ key ] ) ; } else { $ reviewItems [ $ key ] -> spdescription = $ spare -> description ; $ reviewItems [ $ key ] -> imagePath = $ spare -> imagePath ; } } $ orders = App \ Orders :: all ( ) ; $ reviewCount = $ reviewItems -> count ( ) ; $ enquiryCount = App \ Enquiries :: all ( ) -> count ( ) ; $ orderItems = Orderitem :: with ( 'spare' , 'order' ) -> where ( 'orderStatus' , '=' , 'purchased' ) -> get ( ) ; foreach ( $ orderItems as $ key => $ orderItem ) { if ( $ orderItem -> spare -> retailer_id != Auth :: user ( ) -> id ) { unset ( $ orderItems [ $ key ] ) ; } } $ ordersCount = $ orderItems -> count ( ) ; $ orderItems = Orderitem :: with ( 'spare' , 'order' ) -> where ( 'orderStatus' , '=' , 'purchased' ) -> orderBy ( 'created_at' , 'desc' ) -> get ( ) ; foreach ( $ orderItems as $ key => $ orderItem ) { if ( $ orderItem -> spare -> retailer_id != Auth :: user ( ) -> id ) { unset ( $ orderItems [ $ key ] ) ; } } $ a = 0 ; foreach ( $ orderItems as $ key => $ orderItem ) { if ( $ a >= 10 ) { unset ( $ orderItems [ $ key ] ) ; } else { $ a = $ a + 1 ; } } $ complainItems = DB :: table ( 'feedback' ) -> where ( 'feedbackType' , '=' , " Complain " ) -> join ( 'orderItem' , 'feedback.orderItem_id' , '=' , 'orderItem.id' ) -> join ( 'users' , 'feedback.user_id' , '=' , 'users.id' ) -> get ( ) ; foreach ( $ complainItems as $ key => $ complainItem ) { $ spare = Spares :: find ( $ complainItem -> spare_id ) ; if ( $ spare -> retailer_id != $ user_id ) { unset ( $ complainItems [ $ key ] ) ; } else { $ complainItems [ $ key ] -> spdescription = $ spare -> description ; $ complainItems [ $ key ] -> imagePath = $ spare -> imagePath ; } } $ complainCount = $ complainItems -> count ( ) ; return View :: make ( 'Retailer/home' ) -> with ( 'reviewCount' , $ reviewCount ) -> with ( 'enquiryCount' , $ enquiryCount ) -> with ( 'ordersCount' , $ ordersCount ) -> with ( 'complainCount' , $ complainCount ) -> with ( 'orders' , $ orders ) -> with ( 'orderItems' , $ orderItems ) ; }
Display a listing of the resource.
Display a listing of the resource .
//        $startDate = date('Y-m-d', strtotime("-1 week"));