mardi 8 août 2017

Bind multiple models to one View Controller in laravel

I am starting to give up on laravel for not being able to follow a certain pattern that I always have been taking for granted !!

let's assume I have the example from this link http://ift.tt/2ultcK3

public function show($id)
{
    $user = $this->users->find($id);

    return view('user.profile', ['user' => $user]);
}

This user model is bound to that controller to be shown in the view. What if I need to inject another model, let's call it plane which is independent from users model (no db relation). So that I have both of them listed in the same view.

In Angular for instance I could create multiple components in the same page and each have their own independent controllers and models.

Aucun commentaire:

Enregistrer un commentaire