Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.2 kB
1
Indexable
Never
private function verifyOrder($order){
        if($order== null){
            return $order;
        }elseif( $order=='desc'){
            return $order;
        }
        return 'asc';
    }
    
    private function verifySort($sort){
        if($order== null){
            return $order;
        }elseif( $order=='desc'){
            return $order;
        }
        return 'asc';
    }
    
    
    public function index(Request $request) {
        $data=[];
        //$data['performances']= Performance::paginate(10);
        $data['orderidasc']=['sort'=> id,'order'=> 'asc'];
        $data['orderiddesc']=['sort'=> id,'order'=> 'desc'];
        //select * from performance order by name limit 0,10
        
        $performance= new Performance();
        $sort=$this-> verifySort($request-> input('sort'));
        $oder= $this-> verifyOrder( $request-> input('order'));
        if($sort!=null && $order!= null){
            $performance=$performance->orderBy($sort, $order);
        }
        $performance = $performance->orderBy('name', 'asc')->paginate(10);
        
        
        $data['performances']= $performance;
        return view('performance.index', $data);
    }