app/Http/Controllers/FrontendController.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()
    {
        $i=0;$j=0;
        $data[0] = SanPham::latest()->get();
        foreach ($data[0] as $dt){
            if($dt->hot==1){
                $data[3][$i++] = $dt;
            } else{
                $data[2][$j++] = $dt;
            }
        }
        $data[1] = NgheNhan::where('trangThai',1)->get();
        return view('frontend.index',['biendata'=>$data]);
    }
public function index ( ) { $ i = 0 ; $ j = 0 ; $ data [ 0 ] = SanPham :: latest ( ) -> get ( ) ; foreach ( $ data [ 0 ] as $ dt ) { if ( $ dt -> hot == 1 ) { $ data [ 3 ] [ $ i ++ ] = $ dt ; } else { $ data [ 2 ] [ $ j ++ ] = $ dt ; } } $ data [ 1 ] = NgheNhan :: where ( 'trangThai' , 1 ) -> get ( ) ; return view ( 'frontend.index' , [ 'biendata' => $ data ] ) ; }
Display a listing of the resource.
Display a listing of the resource .