/** * Class constructor * * @param \Illuminate\Html\HtmlBuilder $html * @param \Illuminate\Routing\UrlGenerator $url * @param \Illuminate\Session\Store $session * @param \Illuminate\Config\Repository $config */ public function __construct(HtmlBuilder $html, UrlGenerator $url, Session $session, Config $config) { $this->url = $url; $this->html = $html; $this->csrfToken = $session->getToken(); $this->config = $config; $this->loadConfig(); $this->session = $session; $this->errors = $session->get('errors'); }
/** * The constructor * * @param HtmlBuilder $html * @param UrlGenerator $url * @param Session $session */ public function __construct(HtmlBuilder $html, UrlGenerator $url, Session $session) { parent::__construct($html, $url, $session->getToken()); $this->session = $session; $this->requiredFields = []; $this->errorFields = []; if ($this->session->has('formhelper-required-fields')) { $this->requiredFields = $this->session->get('formhelper-required-fields'); $this->session->forget('formhelper-required-fields'); } if ($this->session->has('formhelper-error-fields')) { $this->errorFields = $this->session->get('formhelper-error-fields'); $this->session->forget('formhelper-error-fields'); } }
/** * Get the CSRF token value. * * @return string * @static */ public static function getToken() { return \Illuminate\Session\Store::getToken(); }
/** * Generate a hidden field with the current CSRF token. * * @return string */ public function token() { $token = !empty($this->csrfToken) ? $this->csrfToken : $this->session->getToken(); return $this->hidden('_token', $token); }