Closed jayceedaily closed 2 years ago
Hmmm. I'm not sure where to start with this one. Two things I'm thinking:
GetFromFormRequest
strategy (where your problem is happening) doesn't make a request; it just instantiates the form request, so Laravel probably doesn't get to do any binding.One way to verify (2) is to disable the GetFromFormRequest strategies and enable response calls for that endpoint, which should properly bind the model.
Not sure of the best approach here. A lot of people apparently want a full-fledged request in the FormRequest strategy, but I don't know how viable that is. I think a workaround here would be to add a check for the type of the $tenant
value, maybe?
There's now an instantiateFormRequestUsing()
hook that you can use to customise how your requests are created.
@jayceedaily hey did you ever get this resolved? I've got a similar situation and also can't get instantiateFormRequestUsing()
to work correctly... Any help would be appreciated
same here. I cant make this work
What happened?
class TenantController extends Controller { public function update(TenantUpdateRequest $request, Tenant $tenant) { $tenant->update($request->validated());
}
// REQUEST class TenantUpdateRequest extends FormRequest { public function authorize() { return true; }
}
// ROUTE Route::put('tenant/{tenant}', [TenantController::class, 'update'])->name('edit');
Additional info:
dd(request()->route('tenant'))
in TenantUpdateRequest returns the model binding via Postman but only returns the id/integer of the model when runningscribe:generate