I have this model in Organization.php
public function agency()
{
return $this->belongsToMany('App\Agency')->withPivot('status');
}
and this model in Agency.php
public function organizations()
{
return $this->belongsToMany('App\Organization')->withPivot('status');
}
How can I update the status of a specific row in my pivot table? This is my code in the controller:
public function removeAgency(Request $request){
$my_agencies = Organization::find($request['org_id']);
$member = $my_agencies->agency()
->where('agency_organization.agency_id', $request['agency_id'])
->first();
$member->pivot->status = 'removed';
$member->pivot->save();
}
It returns an error saying: "Creating default object from empty value"
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire