Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

juvpengele's avatar

Get the model instance in my form request

I'm using a route model binding. But for the validation, i would like to get the instance of my model ($company) in the form request ($companyRequest)

public function update(CompanyRequest $companyRequest, Company $company) {
    
        $updates = $companyRequest->merge(["active" => $companyRequest->active_check === "on"])
                                                       ->only("name", "phone_number", "address", "active");

        $this->companyRepository->update($updates, $company);

        return back();
 }
0 likes
4 replies
tykus's avatar
tykus
Best Answer
Level 104

Inside the Request object, you can get the route-model bound model instance using:

$this->route('company');
5 likes
dmitry3's avatar

This one also should work

$this->company;
martinbean's avatar

@dmitry3 …but it’s better to be explicit and use $this->route('company') instead.

Not sure your comment was worth bumping a thread that was nearly half a decade old…

Please or to participate in this conversation.