kdomagoj182
4 months ago

Model relations

Posted 4 months ago by kdomagoj182

When echoing $client->name in clients.show.blade.php everything works fine, but when I tried to echo the same thing in results.create.blade.php Laravel throw error Undefined variable. I tried to look in relations and solve the problem. Here is my Client model relations

public function user()
  {
     return $this->belongsTo('App\User');
  }

public function result()
  {
      return $this->hasMany('App\Models\Result');
  }

And my Result model relations

public function user()
{
    return $this->belongsTo('App\User');
}

public function client()
{
    return $this->belongsTo('App\Models\Client');
}

This is my first question about coding so if you need any more information this is the link from git hub https://github.com/kdomagoj182/Seminar/tree/development

Thanks

Please sign in or create an account to participate in this conversation.