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,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\Services\DeletesContact;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanDeleteContact;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteContactControllerLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Deleted Contact',
|
||||
'message' => 'You have successfully deleted a Contact'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var CanDeleteContact */
|
||||
private $canDeleteContact;
|
||||
|
||||
/** @var DeletesContact */
|
||||
private $deletesContact;
|
||||
|
||||
/** @var FetchesContact */
|
||||
private $fetchesContact;
|
||||
|
||||
/**
|
||||
* DeleteContactControllerLogic constructor.
|
||||
* @param CanDeleteContact $canDeleteContact
|
||||
* @param DeletesContact $deletesContact
|
||||
* @param FetchesContact $fetchesContact
|
||||
*/
|
||||
public function __construct(CanDeleteContact $canDeleteContact, DeletesContact $deletesContact, FetchesContact $fetchesContact)
|
||||
{
|
||||
$this->canDeleteContact = $canDeleteContact;
|
||||
$this->deletesContact = $deletesContact;
|
||||
$this->fetchesContact = $fetchesContact;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canDeleteContact->passes();
|
||||
|
||||
$query = $this->fetchesContact->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesContact->execute($query);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user