This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
i m trying to update a specific pivot model data trought a relation but cant seem to find the correct way to make it work.
my relations are as follow: a company belongToMany Licenses (only a Name attribute). in the pivot data table, i have a ExpiryDate
$company->licenses->each(function($license) { if ($license->name = 'some value') { $license->expirydate = new Carbon; } });
but this brings an error as the license model does not have a expirydate attribute of course.
then how can we update an existing pivot data model ?
Isn't it a case sensitivity problem ? You say you have a ExpiryDate and call a expirydate. Not sure at all but that's what I'll check first ;-)
thanks but it is not the issue, actually i found a way but i wonder if there is another way
$relation = $company->licenses; foreach ($relation as $license) { if ($license->code == $data['code']) { $license->pivot->expires_at = Carbon::createFromFormat('d/m/Y', $row[2] ); $license->pivot->save(); } }
Last updated
1-3 of 3