Home > OS >  Method Illuminate\Database\Eloquent\Collection::with does not exist
Method Illuminate\Database\Eloquent\Collection::with does not exist

Time:12-06

Controller

Model

Error

What could be the solution? Thanks in advance!

CodePudding user response:

this line:

$fileValue= T_S_Ticket::where("tstID","=",$id)->get();

return a collection, so when you use 'with' the next line you got this error. to fix it, simply load the relation and take the only result in the same line:

$fileValue= T_S_Ticket::with('fields')->find($id);

CodePudding user response:

the model should be like this

Here is the reference

Please refer to the given link. the parameter should be similar like the example of the given link.

  • Related