samedi 26 septembre 2015

Laravel updating a hasMany relationship

In my system users can have many timesheets, timesheets can have many data.

I'm trying to update the data rows in the data_timesheet table. I'm using this:

$data = ['column_1' => 'value'];

$this->timesheet->whereId($id)->data()->saveMany($data);

However, it's giving me the following error:

Argument 1 passed to Illuminate\Database\Eloquent\Relations\HasOneOrMany::save() must be an instance of Illuminate\Database\Eloquent\Model, array given

I know why it's giving me the error, because I need to send it a model as opposed to an array. How can I send in a model, when the values being passed are from a user form?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire