vendredi 8 novembre 2019

I am getting this error. Method Illuminate\Validation\Validator::validateReqiured does not exist

I am getting this error for validation of form.

Method Illuminate\Validation\Validator::validateReqiured does not exist.

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Event;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationRequired;

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 Illuminate\Validation\ValidationRequired; but same error is appearing. Anyone can help highly be appreciated. Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire