MachineRepository.php
929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Repositories\Business;
use App\Exceptions\Api\ApiException;
use App\Modules\Enums\ErrorCode;
use App\Modules\Models\Machine\Machine;
use App\Modules\Repositories\BaseRepository;
/**
* Class EloquentHistoryRepository.
*/
class MachineRepository extends BaseRepository
{
function getSpotMachine($spot_id)
{
$where = [
['spot_id', '=', $spot_id]
];
$machines_obj = Machine::where($where)->withCount('availableNumber as available_number')->get();
if ($machines_obj == null) {
throw new ApiException(ErrorCode::SPOT_DO_NOT_HAS_MACHINE, trans('api.error.spot_do_not_has_machine'));
}
return $machines_obj;
}
function getSpotMachineList($spot_id)
{
$where = [
['spot_id', '=', $spot_id]
];
$machines_obj = Machine::where($where)->get();
return $machines_obj;
}
}