<?php
namespace App\Models;
use App\Scopes\DeleteScope;
use App\Traits\Instance;
use App\Traits\MysqlTable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class Model extends EloquentModel
{
use MysqlTable;
use Instance;
use HasFactory;
protected $primaryKey = 'id';
public $timestamps = true;
protected $dateFormat = 'U';
const CREATED_AT = 'created_time';
const UPDATED_AT = 'updated_time';
public function getCreatedTimeAttribute()
{
return $this->attributes[self::CREATED_AT];
}
public function getUpdatedTimeAttribute()
{
return $this->attributes[self::UPDATED_AT];
}
protected $is_delete = 1; protected $delete_field = 'is_delete';
public function getIsDelete()
{
return $this->is_delete;
}
public function getDeleteField()
{
return $this->delete_field;
}
protected $guarded = [];
protected static function booted()
{
static::addGlobalScope(new DeleteScope(new static));
}
public static function firstByWhere($where)
{
return self::where($where)->first();
}
}