system/models/base.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
/**
* base.php
*
* @copyright 2020 damicms.com - All Rights Reserved
* @link https://www.guangdawangluo.com
* @author stiffer.chen <chenlin@damicms.com>
* @created 2020-06-2020/6/29 14:39
* @modified 2020-06-2020/6/29 14:39
*/
namespace Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class Base extends Model
{
public $timestamps = false;
protected $modelName = '';
public function __construct(array $attributes = [])
{
if (!$this->table) {
$this->setTable($this->getCurrentClassName());
}
if ($this->primaryKey == 'id') {
$this->setKeyName($this->getPrimaryName());
}
$this->modelName = str_replace('\\', '', Str::snake(static::class));
parent::__construct($attributes);
}
public function getCurrentClassName()
{
return Str::snake(class_basename($this));
}
public function getPrimaryName()
{
return $this->getTable() . '_id';
}
public function getForeignKey()
{
return Str::snake(class_basename($this)) . '_id';
}
public function primaryValue()
{
return $this->{$this->getPrimaryName()};
}
public function getAllFields()
{
return $this->getConnection()->getSchemaBuilder()->getColumnListing($this->getTable());
}
public static function boot()
后面还有 30 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
