Files
dbois/app/Models/Eloquent/BaseModel.php
T
2026-01-09 11:41:28 +01:00

59 lines
1.3 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', 'password', 'salt'];
protected static $oldValue;
public static function boot()
{
parent::boot();
static::creating( function ( $model ) {
static::$oldValue = '';
if ( AUTHENTICATED )
{
$user = User::find(USERID);
$model->created_by = $user->username;
$model->updated_by = $user->username;
}
} );
static::updating( function ( $model ) {
static::$oldValue = json_encode($model->original);
if ( AUTHENTICATED )
{
$user = User::find(USERID);
$model->updated_by = $user->username;
}
} );
}
}