Ad
Too Few Arguments To Function App\Http\Controllers\CategoryController::destroy(), 0 Passed And Exactly 1 Expected
i can not delete it by id
and i have some code here for Model too
class Category extends Model
{
// Table Name
protected $table = 'categories';
// Primary Key
public $primaryKey = 'id';
// TimeStamps
public $timestamps = true;
protected $fillable= ['name','icon'];
public function getAllCategory(){
return DB::table(categories)->get();
}
public function createCategory($name,$icon){
$category= $this->create([
'name' => $name,
'icon' => $icon,
]);
return $category;
}
}
//here is a function in controller:
public function destroy($id)
{
$category = Category::findOrFail($id);
$category->delele();
return redirect('/admin.category');
}
Ad
Answer
I think the problem is in your routes/web.php file You have to pass one argument to destroy method eg:
Route::get('delete_category/{id}', '[email protected]');
And your invoking URL will look like http://127.0.0.1:8000/delete_category/1
Here 1 will take as the value of id
variable
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad