Skip to content

Commit

Permalink
code optimization added
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Sep 5, 2024
1 parent b47819c commit 82c44f4
Show file tree
Hide file tree
Showing 39 changed files with 96 additions and 95 deletions.
4 changes: 2 additions & 2 deletions src/Exceptions/LocalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class LocalException extends Exception
/**
* CoreException constructor.
*
* @param string $message
* @param int $code
* @param string $message
* @param int $code
*/
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Facades/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laraflow\Local\Facades;

use Illuminate\Support\Facades\Facade;
use Laraflow\Local\Locale;
use Laraflow\Local\Services\CityService;
use Laraflow\Local\Services\CountryService;
use Laraflow\Local\Services\CurrencyService;
Expand All @@ -27,6 +28,6 @@ class Local extends Facade
{
protected static function getFacadeAccessor()
{
return \Laraflow\Local\Locale::class;
return Locale::class;
}
}
16 changes: 8 additions & 8 deletions src/Http/Controllers/CityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function store(StoreCityRequest $request): JsonResponse

$city = Local::city()->create($inputs);

if (! $city) {
if (!$city) {
throw (new StoreOperationException)->setModel(config('fintech.local.city_model'));
}

Expand Down Expand Up @@ -95,7 +95,7 @@ public function show(string|int $id): CityResource|JsonResponse

$city = Local::city()->find($id);

if (! $city) {
if (!$city) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.city_model'), $id);
}

Expand Down Expand Up @@ -126,13 +126,13 @@ public function update(UpdateCityRequest $request, string|int $id): JsonResponse

$city = Local::city()->find($id);

if (! $city) {
if (!$city) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.city_model'), $id);
}

$inputs = $request->validated();

if (! Local::city()->update($id, $inputs)) {
if (!Local::city()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.local.city_model'), $id);
}
Expand Down Expand Up @@ -166,11 +166,11 @@ public function destroy(string|int $id)

$city = Local::city()->find($id);

if (! $city) {
if (!$city) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.city_model'), $id);
}

if (! Local::city()->destroy($id)) {
if (!Local::city()->destroy($id)) {

throw (new DeleteOperationException)->setModel(config('fintech.local.city_model'), $id);
}
Expand Down Expand Up @@ -202,11 +202,11 @@ public function restore(string|int $id)

$city = Local::city()->find($id, true);

if (! $city) {
if (!$city) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.city_model'), $id);
}

if (! Local::city()->restore($id)) {
if (!Local::city()->restore($id)) {

throw (new RestoreOperationException)->setModel(config('fintech.local.city_model'), $id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/CountryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function store(StoreCountryRequest $request): JsonResponse

$country = Local::country()->create($inputs);

if (! $country) {
if (!$country) {
throw (new StoreOperationException)->setModel(config('fintech.local.country_model'));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function show(string|int $id): CountryResource|JsonResponse

$country = Local::country()->find($id);

if (! $country) {
if (!$country) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.country_model'), $id);
}

Expand Down Expand Up @@ -127,13 +127,13 @@ public function update(UpdateCountryRequest $request, string|int $id): JsonRespo

$country = Local::country()->find($id);

if (! $country) {
if (!$country) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.country_model'), $id);
}

$inputs = $request->validated();

if (! Local::country()->update($id, $inputs)) {
if (!Local::country()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.local.country_model'), $id);
}
Expand Down Expand Up @@ -167,11 +167,11 @@ public function destroy(string|int $id)

$country = Local::country()->find($id);

if (! $country) {
if (!$country) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.country_model'), $id);
}

if (! Local::country()->destroy($id)) {
if (!Local::country()->destroy($id)) {

throw (new DeleteOperationException)->setModel(config('fintech.local.country_model'), $id);
}
Expand Down Expand Up @@ -203,11 +203,11 @@ public function restore(string|int $id)

$country = Local::country()->find($id, true);

if (! $country) {
if (!$country) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.country_model'), $id);
}

if (! Local::country()->restore($id)) {
if (!Local::country()->restore($id)) {

throw (new RestoreOperationException)->setModel(config('fintech.local.country_model'), $id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/CurrencyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function store(StoreCurrencyRequest $request): JsonResponse

$currency = Local::currency()->create($inputs);

if (! $currency) {
if (!$currency) {
throw (new StoreOperationException)->setModel(config('fintech.local.currency_model'));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function show(string|int $id): CurrencyResource|JsonResponse

$currency = Local::currency()->find($id);

if (! $currency) {
if (!$currency) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.currency_model'), $id);
}

Expand Down Expand Up @@ -127,13 +127,13 @@ public function update(UpdateCurrencyRequest $request, string|int $id): JsonResp

$currency = Local::currency()->find($id);

if (! $currency) {
if (!$currency) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.currency_model'), $id);
}

$inputs = $request->validated();

if (! Local::currency()->update($id, $inputs)) {
if (!Local::currency()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.local.currency_model'), $id);
}
Expand Down Expand Up @@ -167,11 +167,11 @@ public function destroy(string|int $id)

$currency = Local::currency()->find($id);

if (! $currency) {
if (!$currency) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.currency_model'), $id);
}

if (! Local::currency()->destroy($id)) {
if (!Local::currency()->destroy($id)) {

throw (new DeleteOperationException)->setModel(config('fintech.local.currency_model'), $id);
}
Expand Down Expand Up @@ -203,11 +203,11 @@ public function restore(string|int $id)

$currency = Local::currency()->find($id, true);

if (! $currency) {
if (!$currency) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.currency_model'), $id);
}

if (! Local::currency()->restore($id)) {
if (!Local::currency()->restore($id)) {

throw (new RestoreOperationException)->setModel(config('fintech.local.currency_model'), $id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/RegionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function store(StoreRegionRequest $request): JsonResponse

$region = Local::region()->create($inputs);

if (! $region) {
if (!$region) {
throw (new StoreOperationException)->setModel(config('fintech.local.region_model'));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function show(string|int $id): RegionResource|JsonResponse

$region = Local::region()->find($id);

if (! $region) {
if (!$region) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.region_model'), $id);
}

Expand Down Expand Up @@ -127,13 +127,13 @@ public function update(UpdateRegionRequest $request, string|int $id): JsonRespon

$region = Local::region()->find($id);

if (! $region) {
if (!$region) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.region_model'), $id);
}

$inputs = $request->validated();

if (! Local::region()->update($id, $inputs)) {
if (!Local::region()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.local.region_model'), $id);
}
Expand Down Expand Up @@ -167,11 +167,11 @@ public function destroy(string|int $id)

$region = Local::region()->find($id);

if (! $region) {
if (!$region) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.region_model'), $id);
}

if (! Local::region()->destroy($id)) {
if (!Local::region()->destroy($id)) {

throw (new DeleteOperationException)->setModel(config('fintech.local.region_model'), $id);
}
Expand Down Expand Up @@ -203,11 +203,11 @@ public function restore(string|int $id)

$region = Local::region()->find($id, true);

if (! $region) {
if (!$region) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.region_model'), $id);
}

if (! Local::region()->restore($id)) {
if (!Local::region()->restore($id)) {

throw (new RestoreOperationException)->setModel(config('fintech.local.region_model'), $id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/StateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function store(StoreStateRequest $request): JsonResponse

$state = Local::state()->create($inputs);

if (! $state) {
if (!$state) {
throw (new StoreOperationException)->setModel(config('fintech.local.state_model'));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function show(string|int $id): StateResource|JsonResponse

$state = Local::state()->find($id);

if (! $state) {
if (!$state) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.state_model'), $id);
}

Expand Down Expand Up @@ -127,13 +127,13 @@ public function update(UpdateStateRequest $request, string|int $id): JsonRespons

$state = Local::state()->find($id);

if (! $state) {
if (!$state) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.state_model'), $id);
}

$inputs = $request->validated();

if (! Local::state()->update($id, $inputs)) {
if (!Local::state()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.local.state_model'), $id);
}
Expand Down Expand Up @@ -167,11 +167,11 @@ public function destroy(string|int $id)

$state = Local::state()->find($id);

if (! $state) {
if (!$state) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.state_model'), $id);
}

if (! Local::state()->destroy($id)) {
if (!Local::state()->destroy($id)) {

throw (new DeleteOperationException)->setModel(config('fintech.local.state_model'), $id);
}
Expand Down Expand Up @@ -203,11 +203,11 @@ public function restore(string|int $id)

$state = Local::state()->find($id, true);

if (! $state) {
if (!$state) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.state_model'), $id);
}

if (! Local::state()->restore($id)) {
if (!Local::state()->restore($id)) {

throw (new RestoreOperationException)->setModel(config('fintech.local.state_model'), $id);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Controllers/SubregionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function store(StoreSubregionRequest $request): JsonResponse

$subregion = Local::subregion()->create($inputs);

if (! $subregion) {
if (!$subregion) {
throw (new StoreOperationException)->setModel(config('fintech.local.subregion_model'));
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function show(string|int $id): SubregionResource|JsonResponse

$subregion = Local::subregion()->find($id);

if (! $subregion) {
if (!$subregion) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.subregion_model'), $id);
}

Expand Down Expand Up @@ -127,13 +127,13 @@ public function update(UpdateSubregionRequest $request, string|int $id): JsonRes

$subregion = Local::subregion()->find($id);

if (! $subregion) {
if (!$subregion) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.subregion_model'), $id);
}

$inputs = $request->validated();

if (! Local::subregion()->update($id, $inputs)) {
if (!Local::subregion()->update($id, $inputs)) {

throw (new UpdateOperationException)->setModel(config('fintech.local.subregion_model'), $id);
}
Expand Down Expand Up @@ -167,11 +167,11 @@ public function destroy(string|int $id)

$subregion = Local::subregion()->find($id);

if (! $subregion) {
if (!$subregion) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.subregion_model'), $id);
}

if (! Local::subregion()->destroy($id)) {
if (!Local::subregion()->destroy($id)) {

throw (new DeleteOperationException)->setModel(config('fintech.local.subregion_model'), $id);
}
Expand Down Expand Up @@ -203,11 +203,11 @@ public function restore(string|int $id)

$subregion = Local::subregion()->find($id, true);

if (! $subregion) {
if (!$subregion) {
throw (new ModelNotFoundException)->setModel(config('fintech.local.subregion_model'), $id);
}

if (! Local::subregion()->restore($id)) {
if (!Local::subregion()->restore($id)) {

throw (new RestoreOperationException)->setModel(config('fintech.local.subregion_model'), $id);
}
Expand Down
Loading

0 comments on commit 82c44f4

Please sign in to comment.