app/Http/Controllers/StudentController.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(Request $request)
    {
        if(isset($request->search)){
                $search = $request->search;
                $students = Student::where('name','like',"%$search%")->paginate(15);
        }
        else
            $students = Student::paginate(15);
        return response()->json(['data'=>$students]);
    }
public function index ( Request $ request ) { if ( isset ( $ request -> search ) ) { $ search = $ request -> search ; $ students = Student :: where ( 'name' , 'like' , " % $ search % " ) -> paginate ( 15 ) ; } else $ students = Student :: paginate ( 15 ) ; return response ( ) -> json ( [ 'data' => $ students ] ) ; }
Display a listing of the resource.
Display a listing of the resource .