33 lines
706 B
PHP
33 lines
706 B
PHP
<?php
|
|
|
|
namespace plugin\admin\app\repository;
|
|
|
|
use plugin\admin\app\model\OpmDsDevice;
|
|
use plugin\admin\app\repository\exception\EntityNotFoundException;
|
|
|
|
class DeviceRepository extends BaseRepository
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->model = new OpmDsDevice;
|
|
}
|
|
|
|
public static function new(): DeviceRepository
|
|
{
|
|
return new self();
|
|
}
|
|
|
|
/**
|
|
* 根据ID查找设备
|
|
* @throws EntityNotFoundException
|
|
*/
|
|
public function findOrFail(int $id): OpmDsDevice
|
|
{
|
|
$device = $this->scopedQuery()->find($id);
|
|
if (!$device) {
|
|
throw new EntityNotFoundException('设备不存在');
|
|
}
|
|
return $device;
|
|
}
|
|
}
|