Reputation: 687
i'm trying to pass model relation from blade, to vue.js template.
I have 2 models with relation, shortly:
class Emails extends Model
{
public function template()
{
return $this->belongsTo(Template::class);
}
}
and the other one with has many
relation.
With such request $mails = Emails::all();
i can reach templates using blade after foreach like $mail->template
.
But if i pass it to vue.js template <sometemplate :mails="{{$mails}}"
, after foreach mail.template
would be empty.
I know, that i'm doing something wrong, but can't find a solution.
Upvotes: 2
Views: 1016
Reputation: 687
Sorry, found my solution. I had to add with('template') to my request
Upvotes: 2