mardi 27 septembre 2016

Saving a model's relationship?

I'm using Laravel 5.3.

If I do something like this:

$posts = Post::where('id', 1)
    ->with('stats')
    ->first();

Is it possible to save the stats relationship, like:

$posts->stats->num_users = 5;
$posts->stats->save();

Is this right to do or is there a different way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire