Some product rework

This commit is contained in:
Deon George
2022-08-20 23:01:03 +10:00
parent 71b252843c
commit 8d920e1ba1
10 changed files with 256 additions and 232 deletions

View File

@@ -43,6 +43,14 @@ class ProductController extends Controller
->sortBy('name')
->values();
case 'App\Models\Product\Phone':
return Product\Phone::select(['id','supplier_item_id'])
->with(['supplied.supplier_detail.supplier'])
->get()
->map(function($item) { return ['id'=>$item->id,'name'=>sprintf('%s: %s',$item->supplied->supplier_detail->supplier->name,$item->supplied->name)]; })
->sortBy('name')
->values();
default:
throw new \Exception('Unknown type: '.$request->type);
}
@@ -91,7 +99,8 @@ class ProductController extends Controller
if (! $o->exists && $request->name)
$o = Product::where('name',$request->name)->firstOrNew();
return view('a.product.details')
return view('product.details')
->with('breadcrumb',collect(['Products'=>url('a/product')]))
->with('o',$o);
}
@@ -103,6 +112,6 @@ class ProductController extends Controller
*/
public function home()
{
return view('a.product.home');
return view('product.home');
}
}

View File

@@ -775,7 +775,7 @@ class Service extends Model implements IDs
*/
public function getNameShortAttribute()
{
return $this->type->getServiceNameAttribute() ?: 'SID:'.$this->sid;
return ($this->type && $this->type->getServiceNameAttribute()) ? $this->type->getServiceNameAttribute() : 'SID:'.$this->sid;
}
/**
@@ -790,7 +790,7 @@ class Service extends Model implements IDs
*/
public function getNameDetailAttribute()
{
return $this->type->getServiceDescriptionAttribute();
return ($this->type && $this->type->getServiceDescriptionAttribute()) ? $this->type->getServiceDescriptionAttribute() : 'No Description';
}
/**

View File

@@ -53,6 +53,10 @@ class SupplierDetail extends Model
$item = $this->broadbands->where('id',$id);
break;
case 'phone':
$item = $this->phones->where('id',$id);
break;
default:
throw new \Exception('Unknown type: '.$type);
}