/**
* app/models/BaseModel.php
**/
class BaseModel extends Eloquent {
const CREATED_AT = 'createdAt';
const UPDATED_AT = 'updatedAt';
const DELETED_AT = 'deletedAt';
}
/**
* app/models/MySoftDeleTrait.php
* (you can save this file where you like)
**/
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Illuminate\Database\Eloquent\SoftDeletingScope;
trait MySoftDeleteTrait {
use SoftDeletingTrait;
/**
* Boot the soft deleting trait for a model.
*
* @return void
*/
public static function bootMySoftDeleteTrait()
{
static::addGlobalScope(new SoftDeletingScope);
}
/**
* Get the name of the "deleted at" column.
*
* @return string
*/
public function getDeletedAtColumn()
{
return static::DELETED_AT;
}
}
/**
* app/models/User.php
*
**/
use \MySoftDeleteTrait;
class User extends BaseModel {
public $timestamps = true;
protected $dates = ['deletedAt'];
use MySoftDeleteTrait;
/**
* ... etc ...
**/
}
reference : http://laravel-tricks.com/tricks/change-timestamps-column-names