Answer the question
In order to leave comments, you need to log in
Does Laravel have auto-creation of relationships in models?
Hello. In migrations in Laravel, you can specify a secondary key (foreign key). There are 2 questions:
public function developerr()
{
return $this->belongsTo('App\User', 'developer');
}
public function senderr()
{
return $this->belongsTo('App\User', 'sender');
}
...
$table->foreign('sender')->references('id')->on('users');
$table->foreign('developer')->references('id')->on('users');
$task = \App\Task::find(1);
$task->developer->name;
or for this it is necessary to prescribe relationships as above?Answer the question
In order to leave comments, you need to log in
There is so much "magic" in Laravel, do you need to do something yourself, or are you just too lazy?
Answer: you need to prescribe all the dependencies yourself, this is the optimal solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question