DEV Community

YSF
YSF

Posted on

Hello guys can you help me in this Laravel code

this is the html form in '**.blade.php' :

<form action="{{ route('ruby.destroy') }}" method="POST">
      @csrf
      @method('delete')
      <button>delete</button>
</form>
Enter fullscreen mode Exit fullscreen mode

this is the logic code in '**Controller.php' :

public function destroy($MessageId)
    {
        $chat = Ruby::find($MessageId);
        dd($chat);
        //$message->delete();

    }
}
Enter fullscreen mode Exit fullscreen mode

The probleme :

Missing required parameter for [Route: **.destroy] [URI: ********/{**}] [Missing parameter: chat].
Enter fullscreen mode Exit fullscreen mode

PLS contact me to give me help to solve this error
Thanks.

Top comments (8)

Collapse
 
ysf00009 profile image
YSF

PLS help me to fix this error

Collapse
 
sourovpal profile image
Sourov Pal

Hi,
This is Sourov Pal. I am a freelance web developer and Software Developer. I can do one of project for free. If you like my work you will pay me otherwise you don't need to pay. No upfront needed, no contract needed. If you want to outsource your work to me you may knock me.

My what's app no is: +8801919852044
Github Profile: github.com/sourovpal
Thanks

Collapse
 
panchenko91 profile image
Vitaliy Panchenko

try this one:

<form action="{{ route('ruby.destroy', ['chat' => $MessageId]) }}" method="POST">
      @csrf
      @method('delete')
      <button>delete</button>
</form>
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ysf00009 profile image
YSF

Thanks you
Its solved

Collapse
 
maulik0007 profile image
maulik0007
Collapse
 
maulik0007 profile image
maulik0007
Collapse
 
finnne profile image
quangklynk

Hi there!
In destroy function have $MessageId parameter. You should remove this.

Collapse
 
ysf00009 profile image
YSF • Edited

Why, This is the variable to get the message ID to delete it