T
T
Twelfth Doctor2017-06-27 15:34:25
Laravel
Twelfth Doctor, 2017-06-27 15:34:25

Is it possible to update a record in the database like this through the Laravel model?

Hello! Is it possible to update a record in the database like this:
1. Find a record by the primary key and create an object for this record
2. Assign some values ​​to the object's properties
3. Save the object?

$ModelOfRecord = DNS::find($recid);
            $ModelOfRecord->host = $host;
            $ModelOfRecord->type = $type;
            $ModelOfRecord->priority = $priority;
            $ModelOfRecord->content = $content;
            $ModelOfRecord->save();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maddog670, 2017-06-27
@verdex

You can, of course, and often do it https://laravel.com/docs/5.4/eloquent#updates
The doc even says so

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question