first commit
This commit is contained in:
95
app/Core/Service/PropertyChainService.php
Normal file
95
app/Core/Service/PropertyChainService.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Service;
|
||||
|
||||
use App\Core\Repository\PropertyChain\PropertyChainRepository;
|
||||
|
||||
|
||||
use App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Exception;
|
||||
use App\Exceptions\ApiErrorException;
|
||||
|
||||
class PropertyChainService
|
||||
{
|
||||
|
||||
private $propertyChainRepository;
|
||||
|
||||
|
||||
|
||||
public function __construct(
|
||||
PropertyChainRepository $propertyChainRepository
|
||||
|
||||
)
|
||||
{
|
||||
|
||||
$this->propertyChainRepository = $propertyChainRepository;
|
||||
|
||||
}
|
||||
|
||||
public function select($param = [], $column = ['*'])
|
||||
{
|
||||
|
||||
$response = ['status' => -1, 'message' => '', 'data' => null];
|
||||
|
||||
try {
|
||||
|
||||
$data = $this->propertyChainRepository->findByCriteria($param, $column);
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response['message'] = $e->getMessage();
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return output($response);
|
||||
}
|
||||
|
||||
public function getPropertyChains($params){
|
||||
|
||||
$response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500];
|
||||
try {
|
||||
|
||||
$return = [];
|
||||
$searchCriteria = [
|
||||
'criteria' => [
|
||||
['field' => 'status', 'condition' => '=', 'value' => 1]
|
||||
],
|
||||
'orderBy' => [
|
||||
['field' => 'priority','value' => 'ASC']
|
||||
]
|
||||
];
|
||||
|
||||
$searchResult = $this->select($searchCriteria, ['id', 'name', 'loyalty' ]);
|
||||
|
||||
if($searchResult['status'] != 'success'){
|
||||
throw new ApiErrorException($searchResult['message']);
|
||||
}
|
||||
|
||||
$return = $searchResult['data'];
|
||||
|
||||
$response = ['statusCode' => 200, 'status' => true, 'message' => '', 'data' => ['property_chains' =>$return ] ];
|
||||
} catch (ApiErrorException $e) {
|
||||
$response['message'] = implode(', ', $e->getMessageArr());
|
||||
$response['statusCode'] = 400;
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
$response['statusCode'] = 500;
|
||||
}
|
||||
|
||||
return output($response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user