helps you create applications using simple, expressive syntax as well as offers powerful features like an ORM, routing, queues, events, notifications, simple authentication... ...and so much more! 3 — Twitter/GitHub: @cmgmyr
a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table. https://laravel.com/docs/5.6/eloquent 4 — Twitter/GitHub: @cmgmyr
belongs to User hasMany() // Post has many Comment belongsToMany() // Role belongs to many User hasManyThrough() // Country has many Post through User // Use single table morphTo() // Comment can be on Post, Video, Album morphMany() // Post has many Comment // Use pivot table morphToMany() // Post has many Tag morphedByMany() // Tag has many Post 24 — Twitter/GitHub: @cmgmyr
is retrieved from the database. When a new model is saved for the first time, the creating and created events will fire. If a model already existed in the database and the save() method is called, the updating / updated events will fire. However, in both cases, the saving / saved events will fire. https://laravel.com/docs/5.6/eloquent#events 34 — Twitter/GitHub: @cmgmyr
null); $model->hasChanges($changes, $attributes = null); $model->getDirty(); $model->getChanges(); //Indicates if the model exists. $model->exists; //Indicates if the model was inserted during the current request lifecycle. $model->wasRecentlyCreated; 45 — Twitter/GitHub: @cmgmyr
return ucfirst($value); } public function getLastNameAttribute($value) { return ucfirst($value); } public function getEmailAttribute($value) { return new Email($value); } public function getFullNameAttribute() { return "{$this->first_name} {$this->last_name}"; } } 58 — Twitter/GitHub: @cmgmyr
use the User $attributes property! class Post extends Model { public function author() { return $this->belongsTo(User::class)->withDefault(); } } 81 — Twitter/GitHub: @cmgmyr