I'm converting roject from pure PHP to Laravel 4, and I have a problem with converting this query
SELECT * FROM verses,thoughts WHERE verses.id != thoughts.verses_id
I have two tables verse and thought. one verse has one thought. when creating a thought i want to display all the verse whose thoughts has not been created . Im using Laravel 4.2 display the verses it is not listed in thoughts
Turn on debug
mode. lists()
method returns array, which doesn't have join()
method. Plus, you'd probablu want to use relations instead of pure joining.
Assuming you're using Eloquent models:
$thoughts = Thought::all();
$unused_verses = Verse::whereNotIn('id', $thoughts->list('verse_id'))->get();
Then make your list however you want:
foreach ($unused_verses as $verse)
{
// do stuff here...
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community