HY there good morning i can see your post ad i have some suggestion
User Model: Assuming your users table has a primary key column named id, you can define the User model like this:
use Illuminate\Database\Eloquent\Model;
class User extends Model { protected $table = 'users'; https://www.myaarpmedicare.dev/
// Define the relationship to books
public function books()
{
return $this->belongsToMany(Book::class, 'user_books');
}
// Define the relationship to authors through books
public function authors()
{
return $this->belongsToMany(Author::class, 'user_books')
->join('books', 'authors.id', '=', 'books.author_id')
->distinct();
}
}
Thanks and regards RandyMorton