dillingham / formation

Laravel search, sort, and filters
MIT License
0 stars 0 forks source link

Figure out automatic foreign key #33

Open dillingham opened 2 years ago

dillingham commented 2 years ago

FIgure a way to use relationships derived from route or something to get the foreign key Would be nice if AuthorFormation->nest(PostFormation) automatically used $author->posts()

$results = $this->formation()->nest(
      $this->parentFormation(),
      $this->getParentValue()
  )->results();

currently have to define it on either the formation or override getForeignKey on the model:

class AuthorFormation extends Formation
{
    public $model = User::class;

    public $foreignKey = 'author_id';
}