In the controller:

public function destroy(Messages $message) { $message->delete(); return redirect()->route('messages.index')->with('message', 'Запись удалена.') } 

As:

  {!! Form::open(array('route'=>['messages.destroy',$message->id],'method'=>'DELETE')) !!} {!! Form::button('Удалить',['class'=>'btn btn-danger','type'=>'submit']) !!} {!! Form::close() !!} 

In routes.php

  Route::post('messages.destroy', ['as' => 'messages.destroy', 'uses' => 'MessagesController@destroy']); 

Exit error:

ReflectionException in Route.php line 280: Class App \ Http \ Controllers \ MessagesController does not exist

What is the problem?

  • where is the controller? what is it called? what namespace, - Naumov
  • The controller is in the Http folder like all controllers. MessagesController. namespace App \ Http \ Controllers; - satik-stack
  • If you delete the contents of destroy, there are no errors. - satik-stack
  • Can help composer install ? - NPreston
  • And it's better to wrap $message->delete(); in try ... catch and handle a possible error - NPreston

0