Good colleagues, my question is the following, how can I place this form in html without using collective, I'll explain, I'm doing a tutorial and the person in the tutorial makes the following code:
{!! Form::model($category, ['route' => 'categories.update', $category], 'method' => 'PUT) !!}
This code is to update a category, here I leave the controller like this:
public function update(UpdatecategoryRequest $request, Category $category)
{
$category->update($request->all());
return redirect()->route('categories.index');
}
And model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
use HasFactory;
protected $fillable = [
'name', 'description',
];
public function products()
{
return $this->hasMany(Product::class);
}
}
Thanks in advance for any suggestions you can give me.
I try the following:
<form action="{{ Route('categories.update') }}" method="PUT">
@csrf
gives me the following error:
Illuminate\Routing\ Exceptions\UrlGenerationException
Missing required parameter for [Route: categories.update] [URI: categories/{category}] [Missing parameter: category].
I know it tells me that a parameter is missing, but I don't know how to put it.
By default the forms do not support other methods than get and post, for this you must add the method directive and add the method you want to use https://laravel.com/docs/9.x/blade#method-field