$tags = Tutorial::where('draft', '=', 0)->get()->tags()->get(); // Maybe ?
Nope, now i get another error:
Call to undefined method Illuminate\Database\Eloquent\Collection::tags()
Here are all my models and my controller:
Maybe i'm doing something stupid there
Thanks for the help once again
So i have changed my controller to this:
<?php
class HomeController extends BaseController {
public function index()
{
$tutorials = Tutorial::where('draft', '=', 0)->get();
$tags = $tutorials->first()->tags()->get();
return View::make('home', array(
'tags' => $tags,
'tutorials' => $tutorials
));
}
}
Now this is the output:
PHP basics
This course will teach you the basic princeples of PHP
[{"id":"1","name":"php","pivot":{"tutorial_id":"1","tag_id":"1"}},{"id":"2","name":"laravel","pivot":{"tutorial_id":"1","tag_id":"2"}}]
As you can see, i get the title, and the body. But still having problems with the tags. Which i can only grab the first off..
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community