**此路由不支持POST方法。支持的方法:GET,HEAD,PUT。**

时间:2020-01-06 05:27:29

标签: post events methods laravel-5.8

嗨,请帮助我,我收到此错误,我是laravel的新手,请帮助 Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException 该路由不支持POST方法。支持的方法:GET,HEAD,PUT。 / localhost / seam / public / admin_create_event

这是我的路线

 Route::get('/admin_create_event', 'EventController@display');
Route::post('/admin_create_event', 'EventController@store');
Route::get('/admin_update_event', 'EventController@show');

这是我的admin_create_event表

div class="container">
<div class="jumbotron"></div>
<div class="row">
    <div class="col-md-8 col-md-offset-2">
        <div class="panel panel-default">
            <div class="panel-heading" style="background-color: sky-blue; color:black; "> <h4>YLG</h4></div>

            <div class="panel-body">

                <h1> ADD Event </h1>
            <form method="POST" action="{{action('EventController@store')}}">

                {{csrf_field() }}
            <label for="">Enter name of the Event</label>
            <input type="text" class="form-control" name="title" placeholder="Enter The name" /><br/> <br/>

            <label for="">Choose a Color</label>
            <input type="color" class="form-control" name="color" placeholder="Choose a color" /><br/> <br/>

            <label for="">Enter startdate of the Event</label>
            <input type="datetime-local" class="form-control" name="start_date" class="date" placeholder="Enter The start date" /><br/> <br/>

            <label for="">Enter enddate of the Event</label>
            <input type="datetime-local" class="form-control" name="end_date" class="date" placeholder="Enter The end date" /><br/> <br/>

            <input type="submit" name="submit" class="btn btn-primary" value="add Event data"/>

            </form>
                   </div>
                </div>
            </div>
        </div>
    </div>

和我的EventController

  public function index()
{
    $events = Event::all();
    $event = [];

    foreach($events as $row){
        //$enddate = $row->end_date." 24:00:00";
        $event[] = \Calendar::event(
            $row->title,
            false,
            new \DateTime($row->start_date),
            new \DateTime($row->end_date),
            $row->id,
            [
                    'color' => $row->color,
            ]
            );
    }

    $calendar = \Calendar::addEvents($event);
    return view('superadminpage.admin_calendar', compact('events','calendar'));

}

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    //
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function display()
{
    return view('superadminpage.admin_event.admin_create_event');
}
public function store(Request $request)
{
    $this->validate($request,[
        'title' => 'required',
        'color' => 'required',
        'start_date' => 'required',
        'end_date' => 'required',
    ]);

    $events = new Event;

    $events->title = $request->input('title');
    $events->color = $request->input('color');
    $events->start_date = $request->input('start_date');
    $events->end_date = $request->input('end_date');

    $events->save();

    return redirect('admin_calendar')->with('success', 'Events has been added');



}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function show()
{
    $events = Event::all();
    return view('superadminpage.admin_event.admin_update_event')->with('events', $events);
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function edit($id)
{
    $events = Event::find($id);
    return view('superadminpage.admin_event.admin_editform', compact('events', 'id'));
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    $this->validate($request,[
        'title' => 'required',
        'color' => 'required',
        'start_date' => 'required',
        'end_date' => 'required',
    ]);

    $events = Event::find($id);

    $events->title = $request->input('title');
    $events->color = $request->input('color');
    $events->start_date = $request->input('start_date');
    $events->end_date = $request->input('end_date');

    $events->save();

    return redirect('admin_calendar')->with('success', ' has been added');
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    $events = Event::find($id);
    $events->delete();

    return redirect('admin_calendar')->with('success','Data Deleted');
}}

0 个答案:

没有答案