You're using it wrong. What is the extra pivot column here?
It looks like you really need either sync or attach here
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Business Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Business extends Model
{
use HasFactory;
/**
* The roles that belong to the Business
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function cat()
{
return $this->belongsToMany(BusinessCategory::class, 'cat_business', 'business_id' , 'cat_id');
}
}
Business Category Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Business;
class BusinessCategory extends Model
{
use HasFactory;
protected $guarded = [];
public function business()
{
return $this->belongsToMany(Business::class, 'cat_business','business_id', 'cat_id' );
}
}
Trying to use updateexistingpivot
$business = Business::find($id);
$business->cat()->updateExistingPivot($request->cat_id );
Error
Too few arguments to function Illuminate\Database\Eloquent\Relations\BelongsToMany::updateExistingPivot(), 1 passed in D:\xampp\htdocs\finallisting\app\Http\Controllers\BusinessController.php on line 194 and at least 2 expected
What Would be Second Parameter of Povit relation
$business->cat()->updateExistingPivot($request->cat_id , [Second Perameter??] );
@Alex Fts again, as I mentioned earlier I do not know your business logic!
it can add a new category in business but can't remove the old one
Use sync in that case
Please or to participate in this conversation.