74 lines
1.7 KiB
PHP
74 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
|
|
|
|
use Hyperf\Database\Model\Collection;
|
|
|
|
/**
|
|
* @property int $company_id 主键id
|
|
* @property string $company_name 公司名称
|
|
* @property \Carbon\Carbon $created_at 创建时间
|
|
* @property \Carbon\Carbon $updated_at 修改时间
|
|
*/
|
|
class BasicCompany extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'basic_company';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = ['company_id', 'company_name', 'created_at', 'updated_at'];
|
|
|
|
protected string $primaryKey = "company_id";
|
|
|
|
/**
|
|
* 获取信息-单条
|
|
* @param array $params
|
|
* @param array $fields
|
|
* @return object|null
|
|
*/
|
|
public static function getOne(array $params, array $fields = ['*']): object|null
|
|
{
|
|
return self::where($params)->first($fields);
|
|
}
|
|
|
|
/**
|
|
* 获取数据-多
|
|
* @param array $params
|
|
* @param array $fields
|
|
* @return Collection|array
|
|
*/
|
|
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
|
{
|
|
return self::where($params)->get($fields);
|
|
}
|
|
|
|
/**
|
|
* 新增-批量
|
|
* @param array $data 新增数据
|
|
* @return \Hyperf\Database\Model\Model|BasicCompany
|
|
*/
|
|
public static function addBasicCompany(array $data): \Hyperf\Database\Model\Model|BasicCompany
|
|
{
|
|
return self::create($data);
|
|
}
|
|
|
|
/**
|
|
* 修改-批量
|
|
* @param array $params
|
|
* @param array $data
|
|
* @return int
|
|
*/
|
|
public static function editBasicCompany(array $params = [], array $data = []): int
|
|
{
|
|
return self::where($params)->update($data);
|
|
}
|
|
}
|