I have a Client model that hasMany Appointment models. And an Appointment belongs to a Client. I am trying to return results that show me the client's name as well as their list of appointments on an index blade. Here is my code so far:
Client Model
public function appointment()
{
return $this->hasMany(Appointment::class);
}
Appointment Model
public function client()
{
return $this->belongsTo(Client::class);
}
Controlller
$clients = Client::with('appointment')->get();
//dd($clients);
return view('scheduler')->withclients($clients);
Blade
@foreach($clients as $client
@endforeach
How can I print $client name and their list of appointments? I have tried other help regarding this issue but I am not clear where I am going wrong.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire