diff --git a/app/Http/Controllers/SupplierController.php b/app/Http/Controllers/SupplierController.php index 67b549d..4a94b15 100644 --- a/app/Http/Controllers/SupplierController.php +++ b/app/Http/Controllers/SupplierController.php @@ -4,7 +4,6 @@ namespace App\Http\Controllers; use Carbon\Carbon; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Storage; use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit}; use App\Models\{Cost,Supplier,SupplierDetail}; diff --git a/app/Interfaces/ProductItem.php b/app/Interfaces/ProductItem.php index 9e6a71c..56ec556 100644 --- a/app/Interfaces/ProductItem.php +++ b/app/Interfaces/ProductItem.php @@ -6,7 +6,7 @@ use Illuminate\Support\Collection; interface ProductItem { - public function product(); + public function products(); public function supplied(); diff --git a/app/Models/Product/Type.php b/app/Models/Product/Type.php index b583aa1..9ec6d43 100644 --- a/app/Models/Product/Type.php +++ b/app/Models/Product/Type.php @@ -20,11 +20,11 @@ abstract class Type extends Model /** * The product that sells this type * - * @return \Illuminate\Database\Eloquent\Relations\MorphOne + * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ - public function product() + public function products() { - return $this->morphOne(Product::class, null,'model','model_id'); + return $this->morphMany(Product::class, null,'model','model_id'); } /** diff --git a/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php b/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php index 0ef86f9..e093ad7 100644 --- a/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/widget/offerings.blade.php @@ -33,17 +33,17 @@ - @foreach($xx=$offering->items->with(['products.product.services'])->get() as $oo) + @foreach($xx=$offering->items->with(['products.products.services'])->get() as $oo) {{ $oo->id }} - {{ $oo->name_short }} - {{ $oo->name_detail }} + {{ $oo->name }} + {{ $oo->name_long }} {{ $oo->active ? 'YES' : 'NO' }} {{ number_format($oo->setup_cost_taxable,2) }} {{ number_format($oo->base_cost_taxable,2) }} {{ number_format($oo->products->count()) }} - {{ number_format($oo->products->pluck('product')->filter()->count()) }} - {{ number_format(($x=$oo->products->pluck('product.services')->flatten()->filter())->count()) }} + {{ number_format($oo->products->pluck('products')->filter()->count()) }} + {{ number_format(($x=$oo->products->pluck('products')->flatten()->pluck('services')->flatten()->filter())->count()) }} {{ number_format($x->where('active')->count()) }} @endforeach @@ -54,8 +54,8 @@ TOTALS {{ $xx->where('active',TRUE)->count() }} {{ number_format(($x=$xx->pluck('products')->flatten()->filter())->count()) }} - {{ number_format($x->pluck('product')->filter()->count()) }} - {{ number_format(($xxx=$x->pluck('product.services')->flatten()->filter())->count()) }} + {{ number_format($x->pluck('products')->filter()->count()) }} + {{ number_format(($xxx=$x->pluck('products')->flatten()->pluck('services')->flatten()->filter())->count()) }} {{ number_format($xxx->where('active')->count()) }} diff --git a/resources/views/theme/backend/adminlte/supplier/widget/products.blade.php b/resources/views/theme/backend/adminlte/supplier/widget/products.blade.php index 25f327d..6458923 100644 --- a/resources/views/theme/backend/adminlte/supplier/widget/products.blade.php +++ b/resources/views/theme/backend/adminlte/supplier/widget/products.blade.php @@ -34,9 +34,8 @@ - @foreach($xx=$offering->items->with(['products.product.services','products.product.type.supplied','products.product.description'])->get() as $oo) - @foreach($oo->products->pluck('product')->filter() as $po) - + @foreach($xx=$offering->items->with(['products.products.services','products.products.type.supplied','products.products.translate'])->get() as $oo) + @foreach($oo->products->pluck('products')->flatten()->filter() as $po) {{ $po->lid }} {{ $po->name_short }} @@ -59,7 +58,7 @@ TOTALS {{ $xx->where('active',TRUE)->count() }}   - {{ number_format(($xxx=$xx->pluck('products')->flatten()->pluck('product.services')->flatten()->filter())->count()) }} + {{ number_format(($xxx=$xx->pluck('products')->flatten()->pluck('products')->flatten()->pluck('services')->flatten()->filter())->count()) }} {{ number_format($xxx->where('active')->count()) }}