jeudi 10 mars 2016

Undefined variable: request in view

Hi I want to be able to access $request->session from my Messages class but I get the following error - Undefined variable: request (View:.... C:...) my Messages class is a static class which is a helper that out puts and error "class=status-success" this is where I'm having the problem - this is to determine if a field is succesfull or has an error on post back, what can I do to output a state-success class

Routes:

Route::match(['post', 'put'], '/', function()
{
    $request->session->put('post', true);
});

Messages::class

<?php // Code within app\Helpers\Helper.php

namespace App\Helpers;
use App\Http\Controllers\Controller;
use App\Http\Requests\ProductRequest;


class Messages
{

    public static function getClass($field, $errors)
    {


        $class = '';

        if($errors->has($field)) {
            $class = "state-error";
        } else {                
            if(!$errors->has($field) && $request->session->get('post')) {               
                $class = 'state-success';
            }
        }

        return $class;
    }

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire