Laravel: Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException Нет сообщений - PullRequest
0 голосов
/ 07 ноября 2018

Пожалуйста, помогите. Я не могу создать новый объект. Это форма, где будет создана картина. Когда я открываю веб-сайт, он говорит MethodNotAllowedHttpException и не имеет сообщения.

В web.php (маршрут)

Route::post('store','PaintingController@store');

В контроллере

        $last_line = DB::table('art_objs')->orderBy('Id_no', 'DESC')->first();
        $last = $last_line->Id_no;

        $art_objs = new Art_obj(
            ['Artist' => $request->get('Artist'),
            'Year' => $request->get('Year'),
            'Title' => $request->get('Title'),
            'Description' => $request->get('Description'),
            'Origin' => $request->get('Origin'),
            'Epoch' => $request->get('Epoch'),
            'Type_of_art'=>'1',
            'Type_of_coll'=>$request->input('Type_Coll'),
        ]);
        $art_objs->save();

В клинке

<form method="post" action="store">  {{csrf_field()}} 
                <div class="form-group">
                    <label> Title: </label> <input type="text" name="Title" class="form-control" placeholder="Title"/> 
                </div>
                <div class="form-group">
                    <label> Artist: </label> <input type="text" name="Artist" class="form-control" placeholder="Artist" /> 
                </div>
                <div class="form-group">
                    <label> Year: </label> <input type="text" name="Year" class="form-control" placeholder="Year"/> 
                </div>
                <div class="form-group">
                    <label> Origin: </label> <input type="text" name="Origin" class="form-control" placeholder="Origin"/> 
                </div>
                <div class="form-group">
                    <label> Epoch: </label> <input type="text" name="Epoch" class="form-control" placeholder="Epoch"/> 
                </div>
                <div class="form-group">
                    <label> Description: </label> <textarea name="Description" class="form-control" rows="5" placeholder="description"></textarea> 
                </div>
                <div class="form-group">
                <label> Paint type: </label><input type="text" name="Paint_type" class="form-control" placeholder="Paint type"/> 
                </div>
                <div class="form-group">
                <label> Drawn on: </label><input type="text" name="Drawn_on" class="form-control" placeholder="Drawn on" /> 
                </div>
                <div class="form-group">
                <label> Style: </label><input type="text" name="Style" class="form-control" placeholder="Style"/> 
                <div class="form-group"> 
                    <input type="submit" class="btn btn-primary" value="CREATE" /> 
                </div>
                <input type="hidden" name="_method" value="PATCH" /> 
            </form>

enter image description here

Ответы [ 3 ]

0 голосов
/ 07 ноября 2018

Удалите из формы следующее:

<input type="hidden" name="_method" value="PATCH" />
0 голосов
/ 07 ноября 2018

Ваш url должен быть /painting вместо store. Пожалуйста, попробуйте:

<form method="post" action="/painting"> 
0 голосов
/ 07 ноября 2018

Вы использовали PATCH метод, тогда вы должны изменить route на этот:

Route::patch('store','PaintingController@store');
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...