使用Eloquent检索外键的名称

public function update(Request $request, Currency $currency)
{
    $validData = $request->validate([
        'name' => 'required',
    ]);

    $currency->name = $request ['name'];

    $currency->symbol_url = Image::uploadFileToS3($request, 'symbol_url', $company->name . '/currency/');

    $currency->save();

    return redirect('company');
}

I'm trying to do the update method of the currency controller.

Because of the S3 path, I need to pass down the company name.

The currency already have a company id associated as a foreign key, how can i do the query?

$currency->company->name

It was pretty simple, i was complicating it a lot..

The above answer retrieves the company name for that currency.