how to call model in laravel from controller -


how call model in laravel.

my code is:

use jacopo\authentication\models\guide;  class samplecontroller extends basecontroller  {     public function index()     {         $model='guide';          $guide=$model::where('guide_link','=',"guide")->get();          print_r($guide);     } } 

this produce class 'guide' not found error.

you need add namespace string:

class samplecontroller extends basecontroller  {     public function index()     {         $model='jacopo\authentication\models\guide';          $guide=$model::where('guide_link','=',"guide")->get();          print_r($guide);     } } 

you resolve ioc container, need register first:

app::bind('guide', 'jacopo\authentication\models\guide'); 

and should able to:

$model = app::make('guide');  $guide = $model::where('guide_link','=',"guide")->get(); 

but not option


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -