Im trying to use _construct in Laravel with bellow code
class SongsController extends Controller {
private $song;
public function _construct(Song $song){
$this->song=$song;
}
public function index()
{
$songs=$this->song->get();
return view('songs',compact('songs'));
}
}
but in line: $songs=$this->song->get();
i get an error:
Call to a member function get() on a non-object.
What i do wrong? Btw its run perfect if i do this:
public function index(Song $song)
{
$songs=$song->get();
return view('songs',compact('songs'));
}