当前位置: 首页 > 知识库问答 >
问题:

对未定义函数app\http\controllers\appends()的调用

曹奇文
2023-03-14
Call to undefined function App\Http\Controllers\appends()
  public function index(InstrumentType $instrumentType)
{ 
    $query = "";

    if(request('serial_number')){
        $query = request('serial_number');
    }

    $instruments =  Instrument::where('instrument_type_id', $instrumentType->id)->where('serial_number', 'like', '%'.$query.'%')->paginate(5);
    $instruments = appends($request->query());
    return view('settinginstrument.index', compact('instrumentType', 'instruments'));
}

共有1个答案

汲永嘉
2023-03-14

使用

$instruments->appends($request->query());

而不是

appends($request->query());

试试看:

public function index(Request $request, InstrumentType $instrumentType)
{ 
    $query = "";

    if(request('serial_number')){
        $query = request('serial_number');
    }

    $instruments =  Instrument::where('instrument_type_id', $instrumentType->id)->where('serial_number', 'like', '%'.$query.'%')->paginate(5);
    $instruments = $instruments->appends($request->query());
    return view('settinginstrument.index', compact('instrumentType', 'instruments'));
}
 类似资料: