A
A
Alexander Mikhailenko2018-06-04 14:34:05
ORM
Alexander Mikhailenko, 2018-06-04 14:34:05

How to store a record in a database inside a model using ORM?

Good afternoon, tell me how to work with the database inside the model class. I use ORM eloquent
and connect the necessary classes

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder;

I create my class according to the rules:
class User extends Model
{

    protected $table = 'users';

    protected $fillable = [
        'id',
        'name',
        'surname',
        'email',
        'phone',
        'created_at',
        'updated_at',
        'is_verified',
        'api_key',
        'token',
        'avatar',
        'password'
    ];

But I don’t understand how to use the work with the database inside this model?
use $this->table or use a call on the User class itself?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question