feat : section

This commit is contained in:
2024-11-07 16:17:57 +08:00
parent 7fd07c55d8
commit b6b2627129
11 changed files with 531 additions and 3 deletions

View File

@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Admin\AuthCode;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Collection;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $pid
* @property string $name
* @property int $city_id
* @property string $remark
* @property int $status
* @property string $create_time
* @property string $update_time
*/
class AdminSection extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'admin_section';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
protected array $guarded = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'city_id' => 'integer', 'status' => 'integer'];
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
/**
* @param int $id
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id',$id)->first(['id','pid','name','status','remark']);
}
/**
* @param int $pid
* @return Builder[]|Collection
*/
public function getInfoByPid(int $pid): Collection|array
{
return $this->where('pid',$pid)->get();
}
/**
* 获取所有
* @return array
*/
public function getList(): array
{
return $this
->where('status', AuthCode::SECTION_STATUS_ENABLE)
->get([['id','pid','name','status','remark']])
->toArray();
}
}