We provide creative solutions in form of web and mobile applications to clients around the world, creating apps that get attention and meaningful.

Web Development

Mobile Applications Development

Business Solutions

Odoo ERP Implementation

Wordpress Plugins

WordPress Themes

Laravel Development

Server Security

Server Administration

Mobile Marketing

Pay Per Click (PPC) Management

Conversion Rate Optimization

Email Marketing

Online Presence Analysis

Fell Free To contact Us
We are available from Monday to Friday 9AM to 6PM.


Lahore, Punjab, Pakistan


Laravel Eloquent: Model properties – timestamps, appends etc.

There are a couple of “parameters” of an Eloquent model, as properties of that class. The most mainstream ones are presumably these:

class User extends Model {
    protected $table = 'users';
    protected $fillable = ['email', 'password']; // these fields can be filled with User::create() method
    protected $dates = ['created_at', 'deleted_at']; // these fields can be disabled
    protected $appends = ['field_1', 'field_1']; // additional values returned in JSON

But wait, you can change default behavior of these fields also there are some other options.

   protected $primaryKey = 'uuid'; // It can be other than column "id" in the table
   public $incrementing = false; // We can disable auto-increment of primary key
   protected $perPage = 25; // We can change posts per page for pagination pages.
   const CREATED_AT = 'created_at'; // Specify a custom name to store timestamps
   const UPDATED_AT = 'updated_at'; // Specify a custom name to store timestamps
   public $timestamps = false; // We can disable timestamps totally.

And there’s even more, I’ve listed the most interesting ones. Thanks

Having more than six years of experince developing custom applications with Laravel, WordPress, Zend, and Cordova.

No Comments

Post a Comment