API Resources

Posted 1 year ago by sghimire


Please can you help on this- I am trying to to include book resources api when I am creating API resources for author. This two tables has many to many relationship.

Please see example as below:

//author.php public function author() { return $this-hasMany(AuthorBook::class); }

//book.php Public function book() { return $this-hasMany(AuthorBook::class); }

//authorBook.php Public function authors() { return $this->belongsTo(Author::class); }

Public function books() { return $this->belongsTo(Book::class); }

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