Added hosting report and enabled updating hosting details
This commit is contained in:
@@ -35,6 +35,14 @@ class ProductController extends Controller
|
||||
->sortBy('name')
|
||||
->values();
|
||||
|
||||
case 'App\Models\Product\Host':
|
||||
return Product\Host::select(['id','supplier_host_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);
|
||||
}
|
||||
|
@@ -269,6 +269,20 @@ class ServiceController extends Controller
|
||||
->with('o',$o);
|
||||
}
|
||||
|
||||
public function hosting_list(): View
|
||||
{
|
||||
// @todo Need to add the with path when calculating next_billed and price
|
||||
$o = Service\Host::serviceActive()
|
||||
->serviceUserAuthorised(Auth::user())
|
||||
->select('ab_service__hosting.*')
|
||||
->join('ab_service',['ab_service.id'=>'ab_service__hosting.service_id'])
|
||||
->with(['service.account','service.product.type.supplied.supplier_detail.supplier','tld'])
|
||||
->get();
|
||||
|
||||
return view('r.service.host.list')
|
||||
->with('o',$o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update details about a service
|
||||
*
|
||||
|
@@ -245,7 +245,7 @@ class Product extends Model implements IDs
|
||||
* Get our product type
|
||||
*
|
||||
* @return string
|
||||
* @todo is the test of type and type->supplied necessary?
|
||||
* @todo is the test of type and type->supplied necessary? (It seems some hosting entries have no type, are they old?)
|
||||
*/
|
||||
public function getProductTypeAttribute(): string
|
||||
{
|
||||
@@ -257,9 +257,9 @@ class Product extends Model implements IDs
|
||||
*
|
||||
* @return Model
|
||||
*/
|
||||
public function getSupplierAttribute(): Model
|
||||
public function getSupplierAttribute(): ?Model
|
||||
{
|
||||
return $this->getSuppliedAttribute()->supplier_detail->supplier;
|
||||
return $this->getSuppliedAttribute() ? $this->getSuppliedAttribute()->supplier_detail->supplier : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,9 +267,9 @@ class Product extends Model implements IDs
|
||||
*
|
||||
* @return Model
|
||||
*/
|
||||
public function getSuppliedAttribute(): Model
|
||||
public function getSuppliedAttribute(): ?Model
|
||||
{
|
||||
return $this->type->supplied;
|
||||
return $this->type && $this->type->supplied ? $this->type->supplied : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +401,7 @@ class Product extends Model implements IDs
|
||||
*/
|
||||
public function hasUsage(): bool
|
||||
{
|
||||
return $this->type->hasUsage();
|
||||
return $this->type && $this->type->hasUsage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,15 +2,18 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\DomainTld;
|
||||
use App\Models\HostServer;
|
||||
use App\Traits\NextKey;
|
||||
use Carbon\Carbon;
|
||||
use App\Traits\{ScopeServiceActive,ScopeServiceUserAuthorised};
|
||||
|
||||
class Host extends ServiceType implements ServiceItem
|
||||
{
|
||||
use ScopeServiceActive,ScopeServiceUserAuthorised;
|
||||
use NextKey;
|
||||
const RECORD_ID = 'service__hosting';
|
||||
|
||||
@@ -38,7 +41,7 @@ class Host extends ServiceType implements ServiceItem
|
||||
|
||||
public function getServiceExpireAttribute(): Carbon
|
||||
{
|
||||
// TODO: Implement getServiceExpireAttribute() method.
|
||||
return $this->host_expire;
|
||||
}
|
||||
|
||||
public function getServiceNameAttribute(): string
|
||||
|
Reference in New Issue
Block a user