From 2c3665650caeab4b3ee4d70edf36ac65b84c9005 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 18 Aug 2024 14:02:03 +1000 Subject: [PATCH] Use map() instead of transform(), use fn() instead of function(), consistent coding for form.select --- app/Http/Controllers/ServiceController.php | 6 +++--- app/Jobs/ImportCosts.php | 2 +- app/Models/Product.php | 4 ++-- app/Models/Product/Type.php | 2 +- app/Models/Supplier/Broadband.php | 2 +- .../backend/adminlte/account/widget/supplier.blade.php | 4 ++-- .../views/theme/backend/adminlte/checkout/cart.blade.php | 2 +- .../views/theme/backend/adminlte/checkout/choose.blade.php | 2 +- .../theme/backend/adminlte/product/widget/detail.blade.php | 2 +- .../backend/adminlte/product/widget/selector.blade.php | 2 +- .../backend/adminlte/service/change_pending.blade.php | 2 +- .../adminlte/service/widget/broadband/change.blade.php | 2 +- .../adminlte/service/widget/domain/update.blade.php | 4 ++-- .../adminlte/service/widget/hosting/update.blade.php | 2 +- .../views/theme/backend/adminlte/user/settings.blade.php | 7 ++++--- 15 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index c9fc269..2509682 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -399,11 +399,11 @@ class ServiceController extends Controller // We dynamically create our validation $validator = Validator::make( $request->post(), - $x=collect($o->type->validation()) + collect($o->type->validation()) ->keys() - ->transform(fn($item)=>sprintf('%s.%s',$o->product->category,$item)) + ->map(fn($item)=>sprintf('%s.%s',$o->product->category,$item)) ->combine(array_values($o->type->validation())) - ->transform(fn($item)=>is_string($item) + ->map(fn($item)=>is_string($item) ? preg_replace('/^exclude_without:/',sprintf('exclude_without:%s.',$o->product->category),$item) : $item) ->merge( diff --git a/app/Jobs/ImportCosts.php b/app/Jobs/ImportCosts.php index b7a6a4a..56e3ef3 100644 --- a/app/Jobs/ImportCosts.php +++ b/app/Jobs/ImportCosts.php @@ -62,7 +62,7 @@ class ImportCosts implements ShouldQueue 'PRICETOTAL'=>'Total (inc-GST)' ]; - $this->columns = collect($headers)->transform(function($item) { return strtolower($item); }); + $this->columns = collect($headers)->map(fn($item)=>strtolower($item)); } /** diff --git a/app/Models/Product.php b/app/Models/Product.php index 5928150..a91292f 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -367,7 +367,7 @@ class Product extends Model implements IDs return round($price,2); } - public function accounting(string $provider): Collection + public function accounting(): Collection { $so = ProviderOauth::where('name',self::provider) ->sole(); @@ -379,7 +379,7 @@ class Product extends Model implements IDs ->API() ->getItems() ->pluck('pid','Id') - ->transform(fn($item,$value)=>['id'=>$value,'value'=>$item]) + ->map(fn($item,$value)=>['id'=>$value,'value'=>$item]) ->values(); } diff --git a/app/Models/Product/Type.php b/app/Models/Product/Type.php index ee13908..6ec8ab7 100644 --- a/app/Models/Product/Type.php +++ b/app/Models/Product/Type.php @@ -21,7 +21,7 @@ abstract class Type extends Model */ final public function products() { - return $this->morphMany(Product::class, null,'model','model_id'); + return $this->morphMany(Product::class,null,'model','model_id'); } /** diff --git a/app/Models/Supplier/Broadband.php b/app/Models/Supplier/Broadband.php index e77f42d..8572552 100644 --- a/app/Models/Supplier/Broadband.php +++ b/app/Models/Supplier/Broadband.php @@ -140,7 +140,7 @@ class Broadband extends Type } if ($config->has('metric') AND $config->get('metric')) - $result->transform(function($item) use ($config,$ceil) { + $result->map(function($item) use ($config,$ceil) { return $ceil ? (int)ceil($item/$config->get('metric')) : $item/$config->get('metric'); diff --git a/resources/views/theme/backend/adminlte/account/widget/supplier.blade.php b/resources/views/theme/backend/adminlte/account/widget/supplier.blade.php index 927c346..bd43930 100644 --- a/resources/views/theme/backend/adminlte/account/widget/supplier.blade.php +++ b/resources/views/theme/backend/adminlte/account/widget/supplier.blade.php @@ -27,7 +27,7 @@ @endforeach - @if(($x=Supplier::active()->whereNotIn('id',$o->suppliers->pluck('id'))->orderBy('name')->get())->count()) + @if(($x=Supplier::active()->whereNotIn('id',$o->suppliers->pluck('id'))->orderBy(DB::raw('UPPER(name)'))->get())->count()) @@ -36,7 +36,7 @@
- +
diff --git a/resources/views/theme/backend/adminlte/checkout/cart.blade.php b/resources/views/theme/backend/adminlte/checkout/cart.blade.php index c5e2e99..cc81526 100644 --- a/resources/views/theme/backend/adminlte/checkout/cart.blade.php +++ b/resources/views/theme/backend/adminlte/checkout/cart.blade.php @@ -31,7 +31,7 @@ - + diff --git a/resources/views/theme/backend/adminlte/checkout/choose.blade.php b/resources/views/theme/backend/adminlte/checkout/choose.blade.php index f4afba3..a057cee 100644 --- a/resources/views/theme/backend/adminlte/checkout/choose.blade.php +++ b/resources/views/theme/backend/adminlte/checkout/choose.blade.php @@ -26,7 +26,7 @@
- +
diff --git a/resources/views/theme/backend/adminlte/product/widget/detail.blade.php b/resources/views/theme/backend/adminlte/product/widget/detail.blade.php index 9754dcc..76b60de 100644 --- a/resources/views/theme/backend/adminlte/product/widget/detail.blade.php +++ b/resources/views/theme/backend/adminlte/product/widget/detail.blade.php @@ -42,7 +42,7 @@
- +
diff --git a/resources/views/theme/backend/adminlte/product/widget/selector.blade.php b/resources/views/theme/backend/adminlte/product/widget/selector.blade.php index 303326e..fc9befd 100644 --- a/resources/views/theme/backend/adminlte/product/widget/selector.blade.php +++ b/resources/views/theme/backend/adminlte/product/widget/selector.blade.php @@ -12,7 +12,7 @@
- +
diff --git a/resources/views/theme/backend/adminlte/service/change_pending.blade.php b/resources/views/theme/backend/adminlte/service/change_pending.blade.php index 9a5d647..8a5babb 100644 --- a/resources/views/theme/backend/adminlte/service/change_pending.blade.php +++ b/resources/views/theme/backend/adminlte/service/change_pending.blade.php @@ -41,7 +41,7 @@ + :options="Product::get()->filter(fn($item)=>$item->category === $np->category)->sortBy('name')->sortByDesc('active')->map(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/> diff --git a/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php b/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php index 7d3d888..a201e68 100644 --- a/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/broadband/change.blade.php @@ -3,7 +3,7 @@ + :options="Product::active()->get()->filter(fn($item)=>get_class($item->type) === Broadband::class)->sortBy('name')->sortByDesc('active')->map(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/> NOTE: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is. diff --git a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php index 6055614..4f386b1 100644 --- a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php @@ -18,7 +18,7 @@
- +
@@ -28,7 +28,7 @@
- +
diff --git a/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php index 803705b..81d98cd 100644 --- a/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/hosting/update.blade.php @@ -16,7 +16,7 @@
- +
diff --git a/resources/views/theme/backend/adminlte/user/settings.blade.php b/resources/views/theme/backend/adminlte/user/settings.blade.php index 9664c88..0346924 100644 --- a/resources/views/theme/backend/adminlte/user/settings.blade.php +++ b/resources/views/theme/backend/adminlte/user/settings.blade.php @@ -1,3 +1,6 @@ + +@use(App\Models\Country) + @extends('adminlte::layouts.app') @section('htmlheader_title') @@ -14,8 +17,6 @@ {{ ($o??$user)->role }} @endsection -@use(App\Models\Country) - @section('main-content')
@@ -93,7 +94,7 @@
- +