Using morphTo() on services, added Ezypay payment Import
This commit is contained in:
parent
41d6a07196
commit
253eb55c19
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,4 +13,3 @@ yarn-error.log
|
||||
.env
|
||||
.DS_Store
|
||||
storage/debugbar
|
||||
public/css/app.css
|
||||
|
25
app/Classes/Payments.php
Normal file
25
app/Classes/Payments.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
abstract class Payments
|
||||
{
|
||||
abstract protected function connect(string $url,array $args=[]);
|
||||
abstract public function getCustomers(): Collection;
|
||||
abstract public function getDebits($opt=[]): Collection;
|
||||
abstract public function getSettlements($opt=[]): Collection;
|
||||
|
||||
protected function getClient(string $base_uri): Client
|
||||
{
|
||||
return new Client(['base_uri'=>$base_uri]);
|
||||
}
|
||||
|
||||
protected function mustPause()
|
||||
{
|
||||
return Cache::get('api_throttle');
|
||||
}
|
||||
}
|
61
app/Classes/Payments/Ezypay.php
Normal file
61
app/Classes/Payments/Ezypay.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Payments;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\Payments;
|
||||
|
||||
class Ezypay extends Payments
|
||||
{
|
||||
protected function connect(string $url,array $args=[])
|
||||
{
|
||||
if ($x=$this->mustPause()) {
|
||||
Log::error('API Throttle, waiting .',['m'=>__METHOD__]);
|
||||
sleep($x);
|
||||
}
|
||||
|
||||
$client = $this->getClient(config('services.ezypay.base_uri'));
|
||||
|
||||
$result = $client->request('GET',$url.($args ? '?'.http_build_query($args) : ''),[
|
||||
'headers' => [
|
||||
'Authorization'=>'Basic '.base64_encode(config('services.ezypay.token_user').':'),
|
||||
'Accept'=>'application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$api_remain = Arr::get($result->getHeader('X-RateLimit-Remaining'),0);
|
||||
$api_reset = Arr::get($result->getHeader('X-RateLimit-Reset'),0);
|
||||
|
||||
if ($api_remain == 0) {
|
||||
Log::error('API Throttle.',['m'=>__METHOD__]);
|
||||
Cache::put('api_throttle',$api_reset,now()->addSeconds($api_reset));
|
||||
}
|
||||
|
||||
return json_decode($result->getBody()->getContents());
|
||||
}
|
||||
|
||||
public function getCustomers(): Collection
|
||||
{
|
||||
return Cache::remember(__METHOD__,86400,function() {
|
||||
return collect($this->connect('customers'));
|
||||
});
|
||||
}
|
||||
|
||||
public function getDebits($opt=[]): Collection
|
||||
{
|
||||
return Cache::remember(__METHOD__.http_build_query($opt),86400,function() use ($opt) {
|
||||
return Collect($this->connect('debits'.($opt ? '?'.http_build_query($opt) : '')));
|
||||
});
|
||||
}
|
||||
|
||||
public function getSettlements($opt=[]): Collection
|
||||
{
|
||||
return Cache::remember(__METHOD__.http_build_query($opt),86400,function() use ($opt) {
|
||||
return Collect($this->connect('settlements/'.config('services.ezypay.guid').($opt ? '?'.http_build_query($opt) : '')));
|
||||
});
|
||||
}
|
||||
}
|
115
app/Console/Commands/EzypayImport.php
Normal file
115
app/Console/Commands/EzypayImport.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use App\Classes\Payments\Ezypay;
|
||||
use App\Models\{Account,AccoutBilling,Checkout,Payment};
|
||||
|
||||
class EzypayImport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'payments:ezypay';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Retrieve payments from Ezypay';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/*
|
||||
DB::listen(function($query) {
|
||||
$this->warn('- SQL:'.json_encode(['sql'=>$query->sql,'binding'=>$query->bindings]));
|
||||
});
|
||||
*/
|
||||
|
||||
$poo = new Ezypay();
|
||||
|
||||
// Get our checkout IDs for this plugin
|
||||
$cos = Checkout::where('plugin',config('services.ezypay.plugin'))->pluck('id');
|
||||
|
||||
foreach ($poo->getCustomers() as $c)
|
||||
{
|
||||
if ($c->BillingStatus == 'Inactive')
|
||||
{
|
||||
$this->info(sprintf('Ignoring INACTIVE: [%s] %s %s',$c->EzypayReferenceNumber,$c->Firstname,$c->Surname));
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// Load Direct Debit Details
|
||||
$ab = AccoutBilling::whereIN('checkout_id',$cos)->where('checkout_data',$c->EzypayReferenceNumber)->first();
|
||||
|
||||
if (! $ab)
|
||||
{
|
||||
$this->warn(sprintf('Missing: [%s] %s %s',$c->EzypayReferenceNumber,$c->Firstname,$c->Surname));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find the last payment logged
|
||||
$last = Carbon::createFromTimestamp(Payment::whereIN('checkout_id',$cos)->where('account_id',$ab->service->account_id)->max('date_payment'));
|
||||
|
||||
$o = $poo->getDebits([
|
||||
'customerId'=>$c->Id,
|
||||
'dateFrom'=>$last->format('Y-m-d'),
|
||||
'dateTo'=>$last->addQuarter()->format('Y-m-d'),
|
||||
'pageSize'=>100,
|
||||
]);
|
||||
|
||||
// Load the payments
|
||||
if ($o->count())
|
||||
{
|
||||
foreach ($o->reverse() as $p)
|
||||
{
|
||||
// If not success, ignore it.
|
||||
if (! $p->Status == 'Success')
|
||||
continue;
|
||||
|
||||
$pd = Carbon::createFromFormat('Y-m-d?H:i:s.u',$p->Date);
|
||||
$lp = $ab->service->account->payments->last();
|
||||
|
||||
if ($lp AND (($pd == $lp->date_payment) OR ($p->Id == $lp->checkout_data)))
|
||||
continue;
|
||||
|
||||
// New Payment
|
||||
$po = new Payment;
|
||||
$po->site_id = 1; // @todo
|
||||
$po->date_payment = $pd;
|
||||
$po->checkout_id = '999'; // @todo
|
||||
$po->checkout_data = $p->Id;
|
||||
$po->total_amt = $p->Amount;
|
||||
$ab->service->account->payments()->save($po);
|
||||
|
||||
$this->info(sprintf('Recorded: [%s] %s %s (%s)',$c->EzypayReferenceNumber,$c->Firstname,$c->Surname,$po->id));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ class UserAccountMerge extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
protected $description = 'This utility will create a User account from the Account entries';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
|
@ -12,6 +12,6 @@ class EncryptCookies extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'toggleState',
|
||||
];
|
||||
}
|
||||
|
@ -16,13 +16,14 @@ class Account extends Model
|
||||
|
||||
protected $appends = [
|
||||
'active_display',
|
||||
'name',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
];
|
||||
protected $visible = [
|
||||
'id',
|
||||
'company',
|
||||
'active_display',
|
||||
'name',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
];
|
||||
@ -40,6 +41,11 @@ class Account extends Model
|
||||
return $this->belongsTo(Language::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
@ -55,11 +61,6 @@ class Account extends Model
|
||||
return sprintf('<span class="btn-sm btn-block btn-%s text-center">%s</span>',$this->active ? 'success' : 'danger',$this->active ? 'Active' : 'Inactive');
|
||||
}
|
||||
|
||||
public function getCompanyAttribute($value)
|
||||
{
|
||||
return $value ? $value : $this->user->SurFirstName;
|
||||
}
|
||||
|
||||
public function getAccountIdAttribute()
|
||||
{
|
||||
return sprintf('%02s-%04s',$this->site_id,$this->id);
|
||||
@ -70,6 +71,11 @@ class Account extends Model
|
||||
return sprintf('<a href="/r/account/view/%s">%s</a>',$this->id,$this->account_id);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->company ?: $this->user->SurFirstName;
|
||||
}
|
||||
|
||||
public function getServicesCountHtmlAttribute()
|
||||
{
|
||||
return sprintf('%s <small>/%s</small>',$this->services->where('active',TRUE)->count(),$this->services->count());
|
||||
|
18
app/Models/AccoutBilling.php
Normal file
18
app/Models/AccoutBilling.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\OrderServiceOptions;
|
||||
|
||||
class AccoutBilling extends Model
|
||||
{
|
||||
protected $table = 'ab_account_billing';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
}
|
24
app/Models/Base/ServiceType.php
Normal file
24
app/Models/Base/ServiceType.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Base;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
abstract class ServiceType extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
public $timestamps = FALSE;
|
||||
public $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* @NOTE: The service_id column could be discarded, if the id column=service_id
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphOne
|
||||
*/
|
||||
public function service()
|
||||
{
|
||||
return $this->morphOne(Service::class,'type','model','id');
|
||||
}
|
||||
}
|
16
app/Models/Checkout.php
Normal file
16
app/Models/Checkout.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Checkout extends Model
|
||||
{
|
||||
protected $table = 'ab_checkout';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
}
|
16
app/Models/Module.php
Normal file
16
app/Models/Module.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Module extends Model
|
||||
{
|
||||
protected $table = 'ab_module';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function record()
|
||||
{
|
||||
return $this->hasOne(Record::class);
|
||||
}
|
||||
}
|
@ -4,10 +4,20 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
const RECORD_ID = 'payment';
|
||||
|
||||
public $incrementing = FALSE;
|
||||
protected $table = 'ab_payment';
|
||||
protected $dates = ['date_payment'];
|
||||
protected $dateFormat = 'U';
|
||||
protected $with = ['account.country.currency','items'];
|
||||
|
||||
protected $appends = [
|
||||
|
@ -21,9 +21,14 @@ class Product extends Model
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service category (from the product)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryAttribute()
|
||||
{
|
||||
return $this->prod_plugin_file;
|
||||
return $this->prod_plugin_file ?: 'Other';
|
||||
}
|
||||
|
||||
public function getContractTermAttribute()
|
||||
|
11
app/Models/Record.php
Normal file
11
app/Models/Record.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Record extends Model
|
||||
{
|
||||
protected $table = 'ab_record_id';
|
||||
public $timestamps = FALSE;
|
||||
}
|
@ -3,30 +3,32 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
public $incrementing = FALSE;
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
|
||||
protected $table = 'ab_service';
|
||||
protected $with = ['product.descriptions','account.language','service_adsl','service_domain.tld','service_ssl','service_voip'];
|
||||
protected $with = ['product.descriptions','account.language'];
|
||||
protected $dates = ['date_last_invoice','date_next_invoice'];
|
||||
public $dateFormat = 'U';
|
||||
|
||||
protected $casts = [
|
||||
'order_info'=>'array',
|
||||
];
|
||||
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
|
||||
protected $appends = [
|
||||
'account_name',
|
||||
'admin_service_id_url',
|
||||
'category',
|
||||
'name',
|
||||
'name_full',
|
||||
'name_short',
|
||||
'next_invoice',
|
||||
'product_category',
|
||||
'product_name',
|
||||
'service_id',
|
||||
'service_id_url',
|
||||
@ -37,12 +39,11 @@ class Service extends Model
|
||||
'account_name',
|
||||
'admin_service_id_url',
|
||||
'active',
|
||||
'category',
|
||||
'data_orig',
|
||||
'id',
|
||||
'name',
|
||||
'name_full',
|
||||
'name_short',
|
||||
'next_invoice',
|
||||
'product_category',
|
||||
'product_name',
|
||||
'service_id',
|
||||
'service_id_url',
|
||||
@ -85,7 +86,7 @@ class Service extends Model
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function orderby()
|
||||
public function orderedby()
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
@ -100,31 +101,6 @@ class Service extends Model
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
|
||||
public function service_adsl()
|
||||
{
|
||||
return $this->belongsTo(ServiceAdsl::class,'id','service_id');
|
||||
}
|
||||
|
||||
public function service_domain()
|
||||
{
|
||||
return $this->belongsTo(ServiceDomain::class,'id','service_id');
|
||||
}
|
||||
|
||||
public function service_host()
|
||||
{
|
||||
return $this->belongsTo(ServiceHost::class,'id','service_id');
|
||||
}
|
||||
|
||||
public function service_ssl()
|
||||
{
|
||||
return $this->belongsTo(ServiceSsl::class,'id','service_id');
|
||||
}
|
||||
|
||||
public function service_voip()
|
||||
{
|
||||
return $this->belongsTo(ServiceVoip::class,'id','service_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Product of the service
|
||||
*
|
||||
@ -135,6 +111,21 @@ class Service extends Model
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function type()
|
||||
{
|
||||
return $this->morphTo(null,'model','id','service_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Only query active categories
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where(function () use ($query) {
|
||||
$query->where('active',TRUE)->orWhereNotIn('order_status',$this->inactive_status);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Find inactive services.
|
||||
*
|
||||
@ -144,57 +135,66 @@ class Service extends Model
|
||||
public function scopeInActive($query)
|
||||
{
|
||||
return $query->where(function () use ($query) {
|
||||
return $query->where('active',FALSE)->orWhereIn('order_status',$this->inactive_status);
|
||||
$query->where('active',FALSE)->orWhereIn('order_status',$this->inactive_status);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Only query active categories
|
||||
* Name of the account for this service
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where(function () use ($query) {
|
||||
return $query->where('active',TRUE)->orWhereNotIn('order_status',$this->inactive_status);
|
||||
});
|
||||
}
|
||||
|
||||
public function getAccountNameAttribute()
|
||||
{
|
||||
return $this->account->company;
|
||||
return $this->account->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Product's Category for this service
|
||||
*
|
||||
*/
|
||||
public function getProductCategoryAttribute(): string
|
||||
{
|
||||
return $this->product->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Product's Short Name for the service
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProductNameAttribute(): string
|
||||
{
|
||||
return $this->product->name($this->account->language);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the short name for the service.
|
||||
* EG:
|
||||
* For ADSL, this would be the phone number,
|
||||
* For Hosting, this would be the domain name, etc
|
||||
*/
|
||||
public function getNameShortAttribute()
|
||||
{
|
||||
return $this->model ? $this->type->name : NULL;
|
||||
}
|
||||
/**
|
||||
* Return the date for the next invoice
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function getNextInvoiceAttribute()
|
||||
{
|
||||
return $this->date_next_invoice ? $this->date_next_invoice->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
//@todo
|
||||
|
||||
public function getAdminServiceIdUrlAttribute()
|
||||
{
|
||||
return sprintf('<a href="/a/service/%s">%s</a>',$this->id,$this->service_id);
|
||||
}
|
||||
|
||||
public function getCategoryAttribute()
|
||||
{
|
||||
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
|
||||
return is_object($this->product) ? $this->product->category : 'Unknown Product';
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
if (! isset($this->ServicePlugin()->name))
|
||||
return 'Unknown';
|
||||
|
||||
return $this->ServicePlugin()->name;
|
||||
}
|
||||
|
||||
public function getNameFullAttribute()
|
||||
{
|
||||
if (! isset($this->ServicePlugin()->full_name))
|
||||
return 'Unknown';
|
||||
|
||||
return $this->ServicePlugin()->full_name;
|
||||
}
|
||||
|
||||
public function getNextInvoiceAttribute()
|
||||
{
|
||||
return $this->date_next_invoice ? $this->date_next_invoice->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will present the Order Info Details
|
||||
*/
|
||||
@ -216,12 +216,6 @@ class Service extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getProductNameAttribute()
|
||||
{
|
||||
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
|
||||
return is_object($this->product) ? $this->product->name($this->account->language) : 'Unknown Product';
|
||||
}
|
||||
|
||||
public function getServiceExpireAttribute()
|
||||
{
|
||||
return 'TBA';
|
||||
|
@ -1,16 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Models\Service_Model as Model;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class ServiceAdsl extends Model
|
||||
class Adsl extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
// @todo column service_id can be removed.
|
||||
protected $table = 'ab_service__adsl';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
18
app/Models/Service/Domain.php
Normal file
18
app/Models/Service/Domain.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
class Domain extends \App\Models\Base\ServiceType
|
||||
{
|
||||
protected $table = 'ab_service__domain';
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s.%s',$this->domain_name,$this->tld->name);
|
||||
}
|
||||
}
|
13
app/Models/Service/Host.php
Normal file
13
app/Models/Service/Host.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
class Host extends \App\Models\Base\ServiceType
|
||||
{
|
||||
protected $table = 'ab_service__hosting';
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s',$this->domain_name);
|
||||
}
|
||||
}
|
@ -1,15 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Models\Service_Model as Model;
|
||||
use App\Traits\NextKey;
|
||||
use App\Classes\SSL;
|
||||
|
||||
class ServiceSsl extends Model
|
||||
class SSL extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
protected $table = 'ab_service__ssl';
|
||||
protected $_o = NULL;
|
||||
|
||||
@ -22,7 +16,7 @@ class ServiceSsl extends Model
|
||||
{
|
||||
if (is_null($this->_o))
|
||||
{
|
||||
$this->_o = new SSL;
|
||||
$this->_o = new \App\Classes\SSL;
|
||||
|
||||
if ($this->cert)
|
||||
$this->_o->crt($this->cert);
|
@ -1,15 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Models\Service_Model as Model;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class ServiceVoip extends Model
|
||||
class Voip extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
protected $table = 'ab_service__voip';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Service_Model as Model;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class ServiceDomain extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
protected $table = 'ab_service__domain';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s.%s',$this->domain_name,$this->tld->name);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Service_Model as Model;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class ServiceHost extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
protected $table = 'ab_service__hosting';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s',$this->domain_name);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Abstract Base Model for Services
|
||||
*/
|
||||
abstract class Service_Model extends Model
|
||||
{
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the server, that will appear on invoices/service displays
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function getNameAttribute();
|
||||
}
|
@ -2,9 +2,13 @@
|
||||
|
||||
/**
|
||||
* Works out the next ID to use for an Eloquent Table.
|
||||
*
|
||||
* If we update records, we update the record_id table
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Module;
|
||||
|
||||
trait NextKey
|
||||
{
|
||||
public static function boot()
|
||||
@ -15,6 +19,16 @@ trait NextKey
|
||||
{
|
||||
$model->id = self::NextId();
|
||||
});
|
||||
|
||||
static::saved(function($model)
|
||||
{
|
||||
if (! $model::RECORD_ID)
|
||||
throw new \Exception('Missing record_id const for '.get_class($model));
|
||||
|
||||
$mo = Module::where('name',$model::RECORD_ID)->firstOrFail();
|
||||
$mo->record->id = $model->id;
|
||||
$mo->record->save();
|
||||
});
|
||||
}
|
||||
|
||||
public static function NextId()
|
||||
|
@ -14,6 +14,7 @@
|
||||
"barryvdh/laravel-snappy": "^0.4.1",
|
||||
"clarkeash/doorman": "^2.0",
|
||||
"creativeorange/gravatar": "^1.0",
|
||||
"doctrine/dbal": "^2.9",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"h4cc/wkhtmltoimage-amd64": "0.12.x",
|
||||
"h4cc/wkhtmltopdf-amd64": "0.12.x",
|
||||
|
233
composer.lock
generated
233
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "80fcfcceeb350efa8358cafb529b17fa",
|
||||
"content-hash": "8825756d6702446213ff7c7dd0beee21",
|
||||
"packages": [
|
||||
{
|
||||
"name": "acacha/user",
|
||||
@ -391,6 +391,237 @@
|
||||
"description": "implementation of xdg base directory specification for php",
|
||||
"time": "2014-10-24T07:27:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/cache",
|
||||
"version": "v1.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/cache.git",
|
||||
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57",
|
||||
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "~7.1"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": ">2.2,<2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"alcaeus/mongo-php-adapter": "^1.1",
|
||||
"doctrine/coding-standard": "^4.0",
|
||||
"mongodb/mongodb": "^1.1",
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"predis/predis": "~1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.8.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Caching library offering an object-oriented API for many cache backends",
|
||||
"homepage": "https://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching"
|
||||
],
|
||||
"time": "2018-08-21T18:01:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/dbal",
|
||||
"version": "v2.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/dbal.git",
|
||||
"reference": "22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/dbal/zipball/22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9",
|
||||
"reference": "22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/cache": "^1.0",
|
||||
"doctrine/event-manager": "^1.0",
|
||||
"ext-pdo": "*",
|
||||
"php": "^7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^5.0",
|
||||
"jetbrains/phpstorm-stubs": "^2018.1.2",
|
||||
"phpstan/phpstan": "^0.10.1",
|
||||
"phpunit/phpunit": "^7.4",
|
||||
"symfony/console": "^2.0.5|^3.0|^4.0",
|
||||
"symfony/phpunit-bridge": "^3.4.5|^4.0.5"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/console": "For helpful console commands such as SQL execution and import of files."
|
||||
},
|
||||
"bin": [
|
||||
"bin/doctrine-dbal"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.9.x-dev",
|
||||
"dev-develop": "3.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\DBAL\\": "lib/Doctrine/DBAL"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.",
|
||||
"homepage": "https://www.doctrine-project.org/projects/dbal.html",
|
||||
"keywords": [
|
||||
"abstraction",
|
||||
"database",
|
||||
"dbal",
|
||||
"mysql",
|
||||
"persistence",
|
||||
"pgsql",
|
||||
"php",
|
||||
"queryobject"
|
||||
],
|
||||
"time": "2018-12-31T03:27:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/event-manager",
|
||||
"version": "v1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/event-manager.git",
|
||||
"reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/a520bc093a0170feeb6b14e9d83f3a14452e64b3",
|
||||
"reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": "<2.9@dev"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^4.0",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\": "lib/Doctrine/Common"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Marco Pivetta",
|
||||
"email": "ocramius@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Doctrine Event Manager component",
|
||||
"homepage": "https://www.doctrine-project.org/projects/event-manager.html",
|
||||
"keywords": [
|
||||
"event",
|
||||
"eventdispatcher",
|
||||
"eventmanager"
|
||||
],
|
||||
"time": "2018-06-11T11:59:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"version": "v1.3.0",
|
||||
|
@ -44,4 +44,10 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
'ezypay' => [
|
||||
'plugin' => 'DD_EZYPAY',
|
||||
'base_uri' => 'https://api.ezypay.com/api/v1/',
|
||||
'token_user' => env('EZYPAY_TOKEN'),
|
||||
'guid' => env('EZYPAY_GUID'),
|
||||
],
|
||||
];
|
||||
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddModelToService extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('ab_service', function (Blueprint $table) {
|
||||
$table->string('model')->nullable();
|
||||
});
|
||||
|
||||
// Go through our services and add the relation
|
||||
foreach (\App\Models\Service\Adsl::all() as $o)
|
||||
$this->update($o);
|
||||
foreach (\App\Models\Service\Domain::all() as $o)
|
||||
$this->update($o);
|
||||
foreach (\App\Models\Service\Host::all() as $o)
|
||||
$this->update($o);
|
||||
foreach (\App\Models\Service\SSL::all() as $o)
|
||||
$this->update($o);
|
||||
foreach (\App\Models\Service\Voip::all() as $o)
|
||||
$this->update($o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('ab_service', function (Blueprint $table) {
|
||||
$table->dropColumn('model');
|
||||
});
|
||||
}
|
||||
|
||||
function update(\Illuminate\Database\Eloquent\Model $o)
|
||||
{
|
||||
$oo = \App\Models\Service::findOrFail($o->service_id);
|
||||
$oo->model = get_class($o);
|
||||
$oo->save();
|
||||
}
|
||||
}
|
10662
public/css/app.css
vendored
Normal file
10662
public/css/app.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
public/plugin/iCheck/square/blue@2x.png
Normal file
BIN
public/plugin/iCheck/square/blue@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
@ -50,8 +50,8 @@
|
||||
},
|
||||
columns: [
|
||||
{ data: "service_id_url" },
|
||||
{ data: "category" },
|
||||
{ data: "name" },
|
||||
{ data: "product_category" },
|
||||
{ data: "name_short" },
|
||||
{ data: "product_name" },
|
||||
{ data: "status" },
|
||||
{ data: "next_invoice" }
|
||||
|
@ -51,7 +51,7 @@
|
||||
},
|
||||
columns: [
|
||||
{ data: "switch_url" },
|
||||
{ data: "company" },
|
||||
{ data: "name" },
|
||||
{ data: "active_display" },
|
||||
{ data: "services_count_html" }
|
||||
],
|
||||
|
@ -59,7 +59,7 @@
|
||||
@endif
|
||||
},
|
||||
{ data: "account_name" },
|
||||
{ data: "name_full" },
|
||||
{ data: "name_short" },
|
||||
{ data: "status" },
|
||||
{ data: "product_name" }
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user