ook. then just save as plain string or json i guess. you still can convert them back into array.
by the way.. the error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.authors_id' in 'where clause' (SQL: select * from `books` where `books`.`authors_id` = 2)
was triggered by $author->books->first() as it expect books to keeps reference to author instead of author having book_id
That's my point all am wanting to do is show the books relating to the author but because there's no ID (as I previously stated) there's no way to do this, is there?
try this. not sure whether this is you looking for. this should resolve your error. but the relationship is one to one
class Authors extends \Eloquent{
public function books()
{
return $this->belongsTo('Books');
}
}
class Books extends \Eloquent{
public function author()
{
return $this->hasOne('Authors');
}
}
<td>{{ $author->books->title }}</td>
Nope, because the relationship isn't ID related.
do you mean you want to get the book from the author's name. $author->books that retrieve books by the author_name stored in books table?
Books table - http://cl.ly/image/1j1W3m1d2304 Authors table - http://cl.ly/image/1e151t2y1i0w
class Authors extends Eloquent{
function books(){
return $this->hasMany('Books', "author","name");
}
}
Can you explain what this is doing please and then what I should in the view?
It's custom fields in the pivot table.
when you call author->books is will find all books with books.author equal to the author name. (that what i understand from your explanation). since the books don't have any key to the author except they have same books.author and author.name, i thought that the only way you can get the books thats belongs to the author.
i hope i get your right this time. or maybe you should start over to explain your issue. this is far from exploding category already. huhu...
Yes I did a pretty shitty job explaining myself I think, sorry about that! Let me try this as you say then report back shortly.
or maybe i misunderstand you.english is not my native language. ;)
maybe so, but i think i didn't explain myself correctly. unless @bashy can see what I mean
Never dealt with CSVs, sorry. I can't really see from 3 pages either :P
OK cheers @bashy I'll keep trying, it'll come to me at some point!
Please or to participate in this conversation.