If you look above posts i posted a link to the books table and you will see it as id 63 & 65 then in authors the author of bates as ID of 6, so the only way to make this relationship is the name.
the id in the books table in for the book not the author, you can rename the author field to author_id and make it an integer and update it with the ids of the authors from the authors table. if not you can update the values of the author field to match the last_name field from the author table.
I can't rename anything as this table comes from a CSV file the client uploads and they have specified it need to stay in this format.
No need to change anything major, just change how the relation works. It's really bad to use a string for it.
I've figured it out the authors table had "Bates" then books table had "bates" no caps B so after fixing that this works kinda now.
so bates has two books but using $book->books->first()->title only shows one result, what else can I use? to return all books (2) for this author? Just use $book->books->title ??
foreach($book->books as $b){
echo $b->title;
}
Thanks @pmall just what I needed.
Please or to participate in this conversation.