mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Update supplier's status (front-end & back-end)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Company Account Status',
|
||||
'message' => 'You have successfully updated the Company Account Status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyStatus */
|
||||
private $updatesCompanyStatus;
|
||||
|
||||
/**
|
||||
* UpdateCompanyStatusLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
UpdatesCompanyStatus $updatesCompanyStatus
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$company_query = $this->updatesCompanyStatus->execute($company, $request->input('status'));
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company_query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user