Following code does not display data. But if I dd the data it works
Livewire Company.php:
public $company;
public function mount(Company $company) {
$this->company = $company;
}
public function render()
{
return view('livewire.company');
}
livewire.company:
<div>
{{$company->name}}</div>
Though if I dd $company->name it works
Web.php:
Route::livewire('/companies/{company}', 'company')->name('show-company');
layouts/app.blade.php:
@livewireStyles @livewire('company') <script src="{{asset('js/app.js')}}"></script> @livewireScripts
Also if I don't use Route Model Binding but look for it like this
$this->company = Company::find($company);
it throws Unresolvable dependency resolving [Parameter #0 [ $company ]]
It looks like you are receiving a model in your mount function but when calling it from layouts/app.blade.php , you do not pass any argument. So, Instead of
@livewire('company')
You can call something like:
@livewire('company',['company' => App\Company::find(1)])
Here I use my first instance of Company model but you can send what you need. But keep in mind that you should pass a model because you receive a model in mount().
Hope it'll work.