feat : section
This commit is contained in:
74
app/Model/AdminSection.php
Normal file
74
app/Model/AdminSection.php
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,12 @@ use Hyperf\DbConnection\Model\Model;
|
||||
* @property int $avatar
|
||||
* @property string $chinese_name
|
||||
* @property string $mobile
|
||||
* @property int $status
|
||||
* @property int $status
|
||||
* @property string $last_login_ip
|
||||
* @property string $last_login_time
|
||||
* @property int $is_del
|
||||
* @property int $role_id
|
||||
* @property int $role_id
|
||||
* @property int $section_id
|
||||
* @property string $create_time
|
||||
* @property string $update_time
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user