Files
dbois/application/models/eloquent/BaseModel.php
T
2017-12-25 20:23:32 +01:00

55 lines
1.1 KiB
PHP

<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 25/12/2017
* Time: 10:20
*/
use \Illuminate\Database\Eloquent\Model as Eloquent;
class BaseModel extends Eloquent {
/**
* The name of the "created at" column.
*
* @var string
*/
const CREATED_AT = 'created_by';
/**
* The name of the "updated at" column.
*
* @var string
*/
const UPDATED_AT = 'last_update_date';
protected $guarded = [];
protected $hidden = ['creation_date', 'last_update_date', 'created_by', 'updated_by'];
protected static $oldValue;
public static function boot()
{
parent::boot();
static::creating( function ( $model ) {
if ( AUTHENTICATED )
{
$user = User::find(USERID);
$model->created_by = $user->username;
$model->updated_by = $user->username;
}
} );
static::updating( function ( $model ) {
if ( AUTHENTICATED )
{
$user = User::find(USERID);
$model->updated_by = $user->username;
}
} );
}
}