Resource with another name besides "$record".
How can I use another variable name in my EditRecord class, other than "$record"? I get an error when I try to do this in the
getPages()
method:
I guess it's looking for record specifically. However, I have a class that checks for a "location" route in the request and I need it to specifically check this. OR I need it to be able to see if {record}
is an instance of Location
, but it seems that {record}
is just a string or an Int, so I don't think that's possible. If anyone knows a way around this, that would be helpful.5 Replies
I don't think you can change that, because it's looking for
$record
in the mount method of the Livewire componentsthat's unfortunate...maybe it's not doable, but it would be great it if also accepted a Model instance instead of just a string|int.
What do you mean?
$record
is a model instancehmm...I thought I remembered the mount method accepting a string or an int.
My situation is that I have the concept of "locations" in my app, where a user can select a location and then functionality related to that specific location becomes available.
so my route would be like
team/2/location/1009/edit
.
I have a "CheckSession" middleware, where I make sure that nothing goes wrong, like the location isn't stored in the session, or something like that:
If the route was named "location", or "1009" was an instance of Location
then I could do the above check if it's an instance of Location
. But doing $request->route('record')
, could be anything..
I think I'll just have to check within my LocationResource
, but I was hoping to be able to just check this universally within the middleware.$record is inferred so you should still be able to check its instanceof