Use map() instead of transform(), use fn() instead of function(), consistent coding for form.select
Some checks failed
Create Docker Image / Build Docker Image (x86_64) (push) Failing after 28s
Create Docker Image / Final Docker Image Manifest (push) Has been skipped

This commit is contained in:
Deon George 2024-08-18 14:02:03 +10:00
parent 5139b26a05
commit 2c3665650c
15 changed files with 23 additions and 22 deletions

View File

@ -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(

View File

@ -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));
}
/**

View File

@ -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();
}

View File

@ -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');

View File

@ -27,7 +27,7 @@
@endforeach
</tbody>
@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())
<tfoot>
<tr>
<td colspan="3">
@ -36,7 +36,7 @@
<div class="row">
<div class="col-6">
<x-leenooks::form.select id="supplier_id" name="supplier_id" icon="fa-handshake" label="Add Supplier" :options="$x->map(function($item) { $item->value = $item->name; return $item; })->toArray()"/>
<x-leenooks::form.select id="supplier_id" name="supplier_id" icon="fa-handshake" label="Add Supplier" :options="$x->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
<div class="col-4">

View File

@ -31,7 +31,7 @@
<input type="hidden" name="type" value="invoice">
<!-- @todo This is currently forcing only paypal -->
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Method" feedback="Payment Method is required" choose="true" :options="Checkout::active()->where('name','ilike','paypal')->orderBy('name')->get()->map(function ($item) { $item->value = $item->name; return $item; })"/>
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Method" feedback="Payment Method is required" choose="true" :options="Checkout::active()->where('name','ilike','paypal')->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<table id="invoices" class="table table-sm w-100">
<tr>

View File

@ -26,7 +26,7 @@
<div class="card-body">
<div class="row">
<div class="col-12 col-lg-4">
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Name" feedback="Payment Name is required" addnew="New Payment" groupby="active" :options="Checkout::orderBy('active','DESC')->orderBy('name')->get()->map(function ($item) { $item->value = $item->name; return $item; })"/>
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Name" feedback="Payment Name is required" addnew="New Payment" groupby="active" :options="Checkout::orderBy('active','DESC')->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
</div>
</div>

View File

@ -42,7 +42,7 @@
<div class="row">
<!-- Product Type -->
<div class="col-12">
<x-leenooks::form.select name="model" icon="fa-list" label="Product" choose="true" groupby="active" :value="get_class($pdo->type)" :options="Product::availableTypes()->transform(fn($item)=>['id'=>$item,'value'=>$item])"/>
<x-leenooks::form.select name="model" icon="fa-list" label="Product" choose="true" groupby="active" :value="get_class($pdo->type)" :options="Product::availableTypes()->map(fn($item)=>['id'=>$item,'value'=>$item])"/>
</div>
</div>

View File

@ -12,7 +12,7 @@
<div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select name="product_id" icon="fa-list" label="Product" choose="true" groupby="active" :value="$po?->id ?? ''" :options="Product::get()->sortBy(fn($item)=>($item->active ? '0' : '1').$item->name)->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name,'active'=>$item->active])"/>
<x-leenooks::form.select name="product_id" icon="fa-list" label="Product" choose="true" groupby="active" :value="$po?->id ?? ''" :options="Product::get()->sortBy(fn($item)=>($item->active ? '0' : '1').$item->name)->map(fn($item)=>['id'=>$item->id,'value'=>$item->name,'active'=>$item->active])"/>
</div>
</div>
</form>

View File

@ -41,7 +41,7 @@
<!-- PRODUCT -->
<x-leenooks::form.select id="product_id" name="broadband[product_id]" icon="fa-list" label="Product" :helper="$o->product->category_name" groupby="active"
:value="$np->id"
:options="Product::get()->filter(fn($item)=>$item->category === $np->category)->sortBy('name')->sortByDesc('active')->transform(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/>
: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/>
</div>
</div>

View File

@ -3,7 +3,7 @@
<x-leenooks::form.select id="product_id" name="product_id" icon="fa-list" label="Product" :helper="$o->category_name" :choose="true"
:value="$o->service->product_id"
:options="Product::active()->get()->filter(fn($item)=>get_class($item->type) === Broadband::class)->sortBy('name')->sortByDesc('active')->transform(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/>
: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/>
<strong>NOTE</strong>: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is.

View File

@ -18,7 +18,7 @@
<div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select id="domain_registrar_id" name="domain[domain_registrar_id]" icon="fa-handshake" label="Registrar" :value="$o->domain_registrar_id" :options="DomainRegistrar::active()->orderBy('name')->get()->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<x-leenooks::form.select id="domain_registrar_id" name="domain[domain_registrar_id]" icon="fa-handshake" label="Registrar" :value="$o->domain_registrar_id" :options="DomainRegistrar::active()->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
<div class="col-12 col-sm-9 col-md-12 col-xl-6">
@ -28,7 +28,7 @@
<div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select id="registrar_ns" name="domain[registrar_ns]" icon="fa-project-diagram" label="DNS Location" :value="$o->registrar_ns" :options="ServiceDomain::select('registrar_ns')->distinct()->orderBy('registrar_ns')->get()->transform(fn($item)=>['id'=>$item->registrar_ns,'value'=>$item->registrar_ns])"/>
<x-leenooks::form.select id="registrar_ns" name="domain[registrar_ns]" icon="fa-project-diagram" label="DNS Location" :value="$o->registrar_ns" :options="ServiceDomain::select('registrar_ns')->distinct()->orderBy('registrar_ns')->get()->map(fn($item)=>['id'=>$item->registrar_ns,'value'=>$item->registrar_ns])"/>
</div>
<div class="col-12 col-sm-9 col-md-12 col-xl-6">

View File

@ -16,7 +16,7 @@
<div class="row">
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
<x-leenooks::form.select id="supplier_host_server_id" name="hosting[supplier_host_server_id]" icon="fa-handshake" label="Registrar" :value="$o->supplier_host_server_id" :options="SupplierHostServer::active()->orderBy('name')->get()->transform(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
<x-leenooks::form.select id="supplier_host_server_id" name="hosting[supplier_host_server_id]" icon="fa-handshake" label="Registrar" :value="$o->supplier_host_server_id" :options="SupplierHostServer::active()->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
</div>

View File

@ -1,3 +1,6 @@
<!-- ($o??$user)=User::class -->
@use(App\Models\Country)
@extends('adminlte::layouts.app')
@section('htmlheader_title')
@ -14,8 +17,6 @@
{{ ($o??$user)->role }}
@endsection
@use(App\Models\Country)
<!-- ($o??$user)=User::class -->
@section('main-content')
<div class="row">
<div class="col">
@ -93,7 +94,7 @@
<div class="row">
<div class="col-12 col-md-6">
<x-leenooks::form.select id="country" name="country_id" icon="fa-globe" label="Country" :value="($o??$user)->country_id ?? ''" :options="Country::select(['id','name'])->active()->get()->map(function($item) { $item->value = $item->name; return $item; })->toArray()"/>
<x-leenooks::form.select id="country" name="country_id" icon="fa-globe" label="Country" :value="($o??$user)->country_id ?? ''" :options="Country::select(['id','name'])->active()->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
</div>
</div>
</div>