init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user