Use map() instead of transform(), use fn() instead of function(), consistent coding for form.select
This commit is contained in:
parent
5139b26a05
commit
2c3665650c
@ -399,11 +399,11 @@ class ServiceController extends Controller
|
|||||||
// We dynamically create our validation
|
// We dynamically create our validation
|
||||||
$validator = Validator::make(
|
$validator = Validator::make(
|
||||||
$request->post(),
|
$request->post(),
|
||||||
$x=collect($o->type->validation())
|
collect($o->type->validation())
|
||||||
->keys()
|
->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()))
|
->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)
|
? preg_replace('/^exclude_without:/',sprintf('exclude_without:%s.',$o->product->category),$item)
|
||||||
: $item)
|
: $item)
|
||||||
->merge(
|
->merge(
|
||||||
|
@ -62,7 +62,7 @@ class ImportCosts implements ShouldQueue
|
|||||||
'PRICETOTAL'=>'Total (inc-GST)'
|
'PRICETOTAL'=>'Total (inc-GST)'
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->columns = collect($headers)->transform(function($item) { return strtolower($item); });
|
$this->columns = collect($headers)->map(fn($item)=>strtolower($item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -367,7 +367,7 @@ class Product extends Model implements IDs
|
|||||||
return round($price,2);
|
return round($price,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function accounting(string $provider): Collection
|
public function accounting(): Collection
|
||||||
{
|
{
|
||||||
$so = ProviderOauth::where('name',self::provider)
|
$so = ProviderOauth::where('name',self::provider)
|
||||||
->sole();
|
->sole();
|
||||||
@ -379,7 +379,7 @@ class Product extends Model implements IDs
|
|||||||
->API()
|
->API()
|
||||||
->getItems()
|
->getItems()
|
||||||
->pluck('pid','Id')
|
->pluck('pid','Id')
|
||||||
->transform(fn($item,$value)=>['id'=>$value,'value'=>$item])
|
->map(fn($item,$value)=>['id'=>$value,'value'=>$item])
|
||||||
->values();
|
->values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class Broadband extends Type
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($config->has('metric') AND $config->get('metric'))
|
if ($config->has('metric') AND $config->get('metric'))
|
||||||
$result->transform(function($item) use ($config,$ceil) {
|
$result->map(function($item) use ($config,$ceil) {
|
||||||
return $ceil
|
return $ceil
|
||||||
? (int)ceil($item/$config->get('metric'))
|
? (int)ceil($item/$config->get('metric'))
|
||||||
: $item/$config->get('metric');
|
: $item/$config->get('metric');
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</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>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<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>
|
||||||
|
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<input type="hidden" name="type" value="invoice">
|
<input type="hidden" name="type" value="invoice">
|
||||||
|
|
||||||
<!-- @todo This is currently forcing only paypal -->
|
<!-- @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">
|
<table id="invoices" class="table table-sm w-100">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-lg-4">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Product Type -->
|
<!-- Product Type -->
|
||||||
<div class="col-12">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<!-- PRODUCT -->
|
<!-- PRODUCT -->
|
||||||
<x-leenooks::form.select id="product_id" name="broadband[product_id]" icon="fa-list" label="Product" :helper="$o->product->category_name" groupby="active"
|
<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"
|
: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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -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"
|
<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"
|
: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.
|
<strong>NOTE</strong>: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is.
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
<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>
|
||||||
|
|
||||||
<div class="col-12 col-sm-9 col-md-12 col-xl-6">
|
<div class="col-12 col-sm-9 col-md-12 col-xl-6">
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
<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>
|
||||||
|
|
||||||
<div class="col-12 col-sm-9 col-md-12 col-xl-6">
|
<div class="col-12 col-sm-9 col-md-12 col-xl-6">
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
<!-- ($o??$user)=User::class -->
|
||||||
|
@use(App\Models\Country)
|
||||||
|
|
||||||
@extends('adminlte::layouts.app')
|
@extends('adminlte::layouts.app')
|
||||||
|
|
||||||
@section('htmlheader_title')
|
@section('htmlheader_title')
|
||||||
@ -14,8 +17,6 @@
|
|||||||
{{ ($o??$user)->role }}
|
{{ ($o??$user)->role }}
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@use(App\Models\Country)
|
|
||||||
<!-- ($o??$user)=User::class -->
|
|
||||||
@section('main-content')
|
@section('main-content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@ -93,7 +94,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-md-6">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user