Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mozew's avatar
Level 6

Too few arguments to function

I am getting the following error while trying to insert into the table categories.

CategoryController.php

public function store(CategoryRequest $request)
{
    $category = auth()->user()->categories($request->all());
    $category->save();
    return redirect(route('categories.index'));
}

User.php

public function categories()
{
    return $this->hasMany(Category::class);
}

but I get this error.

Too few arguments to function Illuminate\Database\Eloquent\Relations\HasOneOrMany::save(), 0 passed in C:\xampp\htdocs\urmiahardware\blog\app\Http\Controllers\Admin\CategoryController.php on line 43 and exactly 1 expected

0 likes
1 reply

Please or to participate in this conversation.