I'd like to improve this piece of code when updating a related model (1 to 1) on laravel and also know if this is right, wrong, right but not recommended, etc. Thanks all.
$user = User::find($id);
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->update();
$tenant = Tenant::where('user_id', $id)->first();
$tenant->suite_number = $request->input('suite_number');
$tenant->update();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire