mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
f8230990f4
This reverts merge request !157
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\General\Eloquent;
|
|
|
|
|
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Psy\Exception\ErrorException;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
abstract class AbstractFetchRecord extends AbstractGetRecord
|
|
{
|
|
|
|
/**
|
|
* @param array|null $filters
|
|
* @return mixed
|
|
*/
|
|
public function execute(array $filters = []){
|
|
|
|
return $this->handler($filters);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Builder $query
|
|
* @return Model
|
|
* @throws ResourceNotFoundException
|
|
*/
|
|
public function getResults(Builder $query, array $param = []): Model {
|
|
if(!$query->exists()){
|
|
$table = $query->getModel()->getTable();
|
|
if($table ==='job_results'){
|
|
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
|
}
|
|
else{
|
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
|
}
|
|
}
|
|
|
|
return $query->first();
|
|
}
|
|
|
|
}
|