0

Undefined property: Illuminate\Validation\Validator::$errors in laravel

here is my controller file how to solve it i think here problem is any namespace where is it i do not know please guide me

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Route; 
use Input; 
use Illuminate\Support\Facades\Redirect; 
use Illuminate\Http\Request;  
use App\models\Designation; 
use Validator;  
use Illuminate\Support\Facades\Response; 
class Cdesigination extends Controller
{
   public $flight;
    public function __construct(){
        $this->flight = new Designation; 
    }
    public function index()
    {   
      return view('designation');
     }  
    public function techer(Request $request) {
          $Validator =Validator::make(array(
        'name'=>Input::get('name'),
         'detail'=>Input::get('detail')
      ),array(
        'name'             => 'required',            
        'detail'            => 'required'
    ));
        if ($Validator->fails()) { 
            return Response::json([
                'success'=>false,
                'error' =>$Validator->errors->toArray()
            ]);

    }
    else{

        $this->flight->name = $request->name;
        $this->flight->detail = $request->detail; 
        $this->flight->save();
         return Response::json([
                'success'=>true]); 
    }
    }
0

1 Answer 1

9
$Validator->errors()->toArray()

Errors() is function, so the braces are important

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.