Is it possible to use sessions in eloquent model
class StructureModel extends Eloquent {
protected $table = 'page';
protected $attributes = array('lng' => Session::get("lngFunction"));
}
Any help?
This is not a Laravel thing, you simple cannot define variables this way in PHP, this is not how PHP works, but you use the construct method:
class StructureModel extends Eloquent {
protected $table = 'page';
protected $attributes = array();
public function __construct()
{
parent::__construct();
$this->attributes = array('lng' => Session::get("lngFunction"));
}
}
$model->some_value = Session::get("lngFunction");).