dimanche 5 mai 2019

sharing variables to all views laravel error

Link to the Answer which i am following;

https://stackoverflow.com/a/29716181/10697521

I tried this way in my code: i want to share these variables to different views.

class BaseController extends Controller {
public $teachers = Teacher::all();
public function __construct() {

   $nations = nation::all();
   $areas = area::all();
   $religions = religion::all();
   $professions = profession::all();
   $qualifs = qualif::all();
   $subjects = subject::all();
   $deglevels= deglevel::all();
   $degtypes= degtype::all();
   $departments= department::all();
   $sections= section::all();

   View::share ( 'teachers', $this->teachers );
   View::share ( 'nations', $nations );
   View::share ( 'religions', $religions );
   View::share ( 'professions', $professions );
   View::share ( 'qualifs', $qualifs );
   View::share ( 'subjects', $subjects );
   View::share ( 'deglevels', $deglevels );
   View::share ( 'degtypes', $degtypes );
   View::share ( 'departments', $departments );
   View::share ( 'sections', $sections );
}
}

class TeachersController extends BaseController{

public function __construct(){
   parent::__construct();
}

public function create()
{

return view('teachers.create');
}

Error: Constant expression contains invalid operations



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire