mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-31 18:34:34 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\Services\ListsContacts;
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanListContacts;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListContactsControllerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Contacts',
|
||||
'message' => 'You have successfully retrieved a list of Contacts'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListContacts */
|
||||
private $canListContacts;
|
||||
|
||||
/** @var ListsContacts */
|
||||
private $listsContacts;
|
||||
|
||||
/**
|
||||
* ListContactsControllerLogic constructor.
|
||||
* @param CanListContacts $canListContacts
|
||||
* @param ListsContacts $listsContacts
|
||||
*/
|
||||
public function __construct(CanListContacts $canListContacts, ListsContacts $listsContacts)
|
||||
{
|
||||
$this->canListContacts = $canListContacts;
|
||||
$this->listsContacts = $listsContacts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canListContacts->passes();
|
||||
|
||||
$query = $this->listsContacts->execute($this->listsContacts->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ContactResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user