Skip to content
Advertisement

I am getting this error. Method IlluminateValidationValidator::validateReqiured does not exist

I am getting this error for validation of form.

Method IlluminateValidationValidator::validateReqiured does not exist.

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppEvent;
use IlluminateSupportFacadesValidator;
use IlluminateValidationValidationRequired;

class EventController extends Controller
{

protected $events;
public function __construct()
{
    $this->property = new Event();
}
/* get all data */
public function getEvents()
{
    $events =Event::latest()->paginate(5);
    return view ('navbar.viewevents',compact('events'))
    ->with('i',(request()->input('page',1)-1)*5);
}

//view event form
public function viewEventForm()
{
    return view('navbar.events');
}

/* Creating Events */
public function addEvents(Request $request)
{
    $validator = Validator::make($request,[
        'e_name' =>'required',
        'venue' =>'required',
        'e_image' =>'rquired|image|mimes:jpg,jpeg,png',
        'e_status' => 'required'
        ]);
    if ($validator->fails()) {
        return Redirect::back()
                        ->withErrors($validator)
                        ->withInput();
                            }

    $events = $this->property->addNewEvent($request);
    return Redirect::back()
            ->with('message','Team member added successfully');
 }

please help to get rid of this error. I had also tried code below.

 $this->validate($request,[
    'e_name' =>'required',
    'venue' =>'required',
    'e_image' =>'rquired|image|mimes:jpg,jpeg,png',
    'e_status' => 'required'
    ]);

I am getting same error for methods. I this code after removing use IlluminateValidationValidationRequired; but same error is appearing. Anyone can help highly be appreciated. Thanks

Advertisement

Answer

Instead of:

use IlluminateSupportFacadesValidator;
use IlluminateValidationValidationRequired;

Try:

use Validator;

Also, on Laravel 5, you can validate with in the request object (no imports needed):

$request->validate([
    'title' => 'bail|required|unique:posts|max:255',
    'body' => 'required',
]);
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement