lundi 4 janvier 2016

How can I load form post data into a model while updating a record in Laravel

I'm trying to update a record with the post data from a form. Every time I'm manually assigning the values from the form to the model and saving the record.

$model = CondoFacilities::find($id);

$model->facility_title = Input::get('facility_title');
$model->facility_description = Input::get('facility_description');
$model->facility_image = $imageName;

$status = $model->save();

Is there any way to assign the form data to the model and save/update the record in Laravel ? Similar to the one in YII2:

$model = $this->findModel($id);

if ($model->load(Yii::$app->request->post())) {
    $model->save();
}

I'm new to Laravel hope this awesome feature is available in Laravel as well.

Thank you for your help.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1JoOMyI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire