У меня есть эти таблицы БД:
author (atr_id pk) // model : Author
category (ctg_id pk) // model : Category
post (pst_id pk, pst_atr_id fk) // model : Post
post_categories (pct_pst_id fk, pct_ctg_id fk) // pivot : PostCategories
как определить параметры hasMany, sharesTo, assignToMany с пользовательскими именами?
Модель: Автор
public function getPosts()
{
return $this->hasMany('App\Post', ?, ?);
}
Модель: Пост
public function getAuthor()
{
return $this->belongsTo('App\Author', ?, ?);
}
public function getCategories()
{
return $this->belongsToMany('App\Category', ?, ?, ?);
}
Модель: Категория
public function getPosts()
{
return $this->belongsToMany('App\Post', ?, ?, ?);
}