Initial commit

This commit is contained in:
omair saleh
2020-08-12 04:16:41 +08:00
commit 57bd2be885
476 changed files with 41783 additions and 0 deletions
@@ -0,0 +1,67 @@
<?php
namespace App\Classes\Modules\Contacts\ControllerLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Contacts\Services\FetchesContact;
use App\Classes\Modules\Contacts\Standards\Rules\CanFetchContact;
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
use App\Http\Resources\ContactResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchContactControllerLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Contact',
'message' => 'You have successfully retrieved a Contact'
];
}
/** @var CanFetchContact */
private $canFetchContact;
/** @var FetchesContact */
private $fetchesContact;
/**
* FetchContactControllerLogic constructor.
* @param CanFetchContact $canFetchContact
* @param FetchesContact $fetchesContact
*/
public function __construct(CanFetchContact $canFetchContact, FetchesContact $fetchesContact)
{
$this->canFetchContact = $canFetchContact;
$this->fetchesContact = $fetchesContact;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
$this->canFetchContact->passes();
$query = $this->fetchesContact->execute(['id' => $request->route('id')]);
return $this->resourceResponse(new ContactResource($query));
} catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}