app/Http/Controllers/api/MeaController.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)
    {
        $name = $request->input('name');
        $where = [];
        if(!empty($name)){
            $where[] = ['name','like',"%$name%"];
        }
        $data = ApitestModel::where($where)->paginate(3)->toArray();
        return json_encode([
            'ret'=>200,
            'msg'=>"添加成功",
            'data'=>$data
        ]);
    }
public function index ( Request $ request ) { $ name = $ request -> input ( 'name' ) ; $ where = [ ] ; if ( ! empty ( $ name ) ) { $ where [ ] = [ 'name' , 'like' , " % $ name % " ] ; } $ data = ApitestModel :: where ( $ where ) -> paginate ( 3 ) -> toArray ( ) ; return json_encode ( [ 'ret' => 200 , 'msg' => " 添加成功", 'data' => $ data ] ) ; }
Display a listing of the resource.
Display a listing of the resource .
// dd($name); // dd($data);