samedi 15 juin 2019

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');

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire