You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
676 B
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Model;
use App\Scopes\CommonTimeScopes;
use Hyperf\DbConnection\Model\Model as BaseModel;
abstract class Model extends BaseModel
{
use CommonTimeScopes;
public static function alias($alias = null)
{
$name = with(new static)->getTable();
if ($alias) {
$name .= ' as ' . $alias;
}
return $name;
}
public static function fromAlias($alias)
{
return static::from(static::alias($alias));
}
public function getRawAttribute($key)
{
if (!$key) {
return null;
}
return $this->attributes[$key] ?? null;
}
}