Initial refactoring work
This commit is contained in:
@@ -39,4 +39,4 @@ class Kernel extends ConsoleKernel
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,4 +36,12 @@ class LoginController extends Controller
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show our themed login page
|
||||
*/
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('adminlte::auth.login');
|
||||
}
|
||||
}
|
||||
|
34
app/Http/Controllers/Auth/SocialLoginController.php
Normal file
34
app/Http/Controllers/Auth/SocialLoginController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Socialite;
|
||||
|
||||
class SocialLoginController extends Controller
|
||||
{
|
||||
public function redirectToProvider($provider)
|
||||
{
|
||||
return Socialite::with($provider)->redirect();
|
||||
}
|
||||
|
||||
public function handleProviderCallback($provider)
|
||||
{
|
||||
$openiduser = Socialite::with($provider)->user();
|
||||
|
||||
$user = Socialite::with($provider)->findOrCreateUser($openiduser);
|
||||
|
||||
Auth::login($user,FALSE);
|
||||
|
||||
/*
|
||||
if (! $user->profile_update)
|
||||
{
|
||||
return redirect()->to(url('settings'));
|
||||
}
|
||||
*/
|
||||
|
||||
return redirect()->intended();
|
||||
}
|
||||
}
|
16
app/Http/Controllers/UserHomeController.php
Normal file
16
app/Http/Controllers/UserHomeController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class UserHomeController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function home()
|
||||
{
|
||||
return View('home');
|
||||
}
|
||||
}
|
14
app/Http/Controllers/WelcomeController.php
Normal file
14
app/Http/Controllers/WelcomeController.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class WelcomeController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
return view('welcome');
|
||||
}
|
||||
|
||||
public function under_construction() {
|
||||
abort(499,'Under Construction');
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\SetSite;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
@@ -36,6 +37,7 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\SetSite::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
@@ -57,6 +59,7 @@ class Kernel extends HttpKernel
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'demoMode' => \Spatie\DemoMode\DemoMode::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'theme' => \Igaster\LaravelTheme\Middleware\setTheme::class,
|
||||
|
@@ -27,7 +27,7 @@ class SetSite
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// @todo Figure out how to know if this is an API call - and deny it if it's not in the database.
|
||||
$so = NULL;
|
||||
$so = new Site;
|
||||
|
||||
if (Schema::hasTable('site'))
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class SetSite
|
||||
}
|
||||
|
||||
// If we dont exist, we'll return a fake model.
|
||||
if (! $so) {
|
||||
if (! $so or ! $so->exists) {
|
||||
$so = (new Site)->sample();
|
||||
}
|
||||
|
||||
@@ -50,4 +50,4 @@ class SetSite
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
protected $table = 'ab_country';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
/**
|
||||
@@ -13,7 +14,7 @@ class Country extends Model
|
||||
*/
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Currency');
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,6 +22,6 @@ class Country extends Model
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany('App\User');
|
||||
return $this->hasMany(\App\User::class);
|
||||
}
|
||||
}
|
@@ -6,13 +6,26 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
// @todo - temp Until Implemented
|
||||
protected $fillable = ['rounding'];
|
||||
protected $table = 'ab_currency';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
const ROUND_HALF_UP = 1;
|
||||
const ROUND_HALF_DOWN = 2;
|
||||
const ROUND_HALF_EVEN = 3;
|
||||
const ROUND_HALF_ODD = 4;
|
||||
|
||||
/**
|
||||
* The accounts in this country
|
||||
*/
|
||||
public function countries()
|
||||
{
|
||||
return $this->hasMany('App\Models\Country');
|
||||
return $this->hasMany(Country::class);
|
||||
}
|
||||
|
||||
public function round($value,$mode=self::ROUND_HALF_UP)
|
||||
{
|
||||
return round($value,$this->rounding,$mode);
|
||||
}
|
||||
}
|
15
app/Models/DomainTld.php
Normal file
15
app/Models/DomainTld.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DomainTld extends Model
|
||||
{
|
||||
protected $table = 'ab_domain_tld';
|
||||
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
}
|
68
app/Models/Invoice.php
Normal file
68
app/Models/Invoice.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
protected $table = 'ab_invoice';
|
||||
protected $dates = ['due_date'];
|
||||
protected $with = ['invoiceitems.taxes','account.country.currency','paymentitems'];
|
||||
|
||||
private $_total = 0;
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class);
|
||||
}
|
||||
|
||||
public function invoiceitems()
|
||||
{
|
||||
return $this->hasMany(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function paymentitems()
|
||||
{
|
||||
return $this->hasMany(PaymentItem::class);
|
||||
}
|
||||
|
||||
public function getDueAttribute()
|
||||
{
|
||||
return $this->currency()->round($this->total - $this->paid);
|
||||
}
|
||||
|
||||
public function getDateDueAttribute()
|
||||
{
|
||||
return $this->due_date->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function getInvoiceNumberAttribute()
|
||||
{
|
||||
return sprintf('%02s-%04s-%04s',$this->site_id,$this->account_id,$this->id);
|
||||
}
|
||||
|
||||
public function getPaidAttribute()
|
||||
{
|
||||
return $this->currency()->round($this->paymentitems->sum('alloc_amt'));
|
||||
}
|
||||
|
||||
public function getTotalAttribute()
|
||||
{
|
||||
if (! $this->_total)
|
||||
{
|
||||
foreach ($this->invoiceitems as $o)
|
||||
{
|
||||
//if ($o->active)
|
||||
$this->_total += $this->currency()->round($o->total);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_total;
|
||||
}
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->account->country->currency;
|
||||
}
|
||||
}
|
46
app/Models/InvoiceItem.php
Normal file
46
app/Models/InvoiceItem.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InvoiceItem extends Model
|
||||
{
|
||||
protected $table = 'ab_invoice_item';
|
||||
protected $with = ['taxes'];
|
||||
|
||||
private $_tax = 0;
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
{
|
||||
return $this->hasMany(InvoiceItemTax::class);
|
||||
}
|
||||
|
||||
public function getSubTotalAttribute()
|
||||
{
|
||||
return $this->quantity * $this->price_base;
|
||||
}
|
||||
|
||||
public function getTaxAttribute()
|
||||
{
|
||||
if (! $this->_tax)
|
||||
{
|
||||
foreach ($this->taxes as $o)
|
||||
{
|
||||
$this->_tax += $o->amount;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_tax;
|
||||
}
|
||||
|
||||
public function getTotalAttribute()
|
||||
{
|
||||
return $this->tax + $this->sub_total;
|
||||
}
|
||||
}
|
15
app/Models/InvoiceItemTax.php
Normal file
15
app/Models/InvoiceItemTax.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InvoiceItemTax extends Model
|
||||
{
|
||||
protected $table = 'ab_invoice_item_tax';
|
||||
|
||||
public function invoice_item()
|
||||
{
|
||||
return $this->belongsTo(InvoiceItem::class);
|
||||
}
|
||||
}
|
10
app/Models/Language.php
Normal file
10
app/Models/Language.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Language extends Model
|
||||
{
|
||||
protected $table = 'ab_language';
|
||||
}
|
16
app/Models/Payment.php
Normal file
16
app/Models/Payment.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
protected $table = 'ab_payment';
|
||||
protected $dates = ['date_payment'];
|
||||
|
||||
public function getPaymentDateAttribute()
|
||||
{
|
||||
return $this->date_payment->format('Y-m-d');
|
||||
}
|
||||
}
|
10
app/Models/PaymentItem.php
Normal file
10
app/Models/PaymentItem.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentItem extends Model
|
||||
{
|
||||
protected $table = 'ab_payment_item';
|
||||
}
|
31
app/Models/Product.php
Normal file
31
app/Models/Product.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
protected $table = 'ab_product';
|
||||
protected $with = ['descriptions'];
|
||||
|
||||
public function descriptions()
|
||||
{
|
||||
return $this->hasMany(ProductTranslate::class);
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the language name
|
||||
*
|
||||
* @param Language $lo
|
||||
*/
|
||||
public function name(Language $lo)
|
||||
{
|
||||
return $this->descriptions->where('language_id',$lo->id)->first()->name;
|
||||
}
|
||||
}
|
10
app/Models/ProductTranslate.php
Normal file
10
app/Models/ProductTranslate.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductTranslate extends Model
|
||||
{
|
||||
protected $table = 'ab_product_translate';
|
||||
}
|
73
app/Models/Service.php
Normal file
73
app/Models/Service.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
protected $table = 'ab_service';
|
||||
protected $dates = ['date_last_invoice','date_next_invoice'];
|
||||
protected $with = ['product.descriptions','account.language','service_adsl','service_domain.tld','service_ssl'];
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo(\App\User::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_ssl()
|
||||
{
|
||||
return $this->belongsTo(ServiceSsl::class,'id','service_id');
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return the associated service model for the product type
|
||||
*/
|
||||
public function getServiceDetail()
|
||||
{
|
||||
switch ($this->product->prod_plugin_file)
|
||||
{
|
||||
case 'ADSL': return $this->service_adsl;
|
||||
case 'DOMAIN': return $this->service_domain;
|
||||
case 'SSL': return $this->service_ssl;
|
||||
default: abort(500,'Havent handled case for: '.$this->product->prod_plugin_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getServiceExpireAttribute()
|
||||
{
|
||||
return 'TBA';
|
||||
}
|
||||
|
||||
public function getNextInvoiceAttribute()
|
||||
{
|
||||
return $this->date_next_invoice->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function getServiceNameAttribute()
|
||||
{
|
||||
if (! isset($this->getServiceDetail()->name)) dd($this,$this->product,$this->getServiceDetail());
|
||||
return sprintf('%s: %s',$this->product->name($this->account->language),$this->getServiceDetail()->name);
|
||||
}
|
||||
|
||||
public function getServiceNumberAttribute()
|
||||
{
|
||||
return sprintf('%02s.%04s.%04s',$this->site_id,$this->account_id,$this->id);
|
||||
}
|
||||
}
|
20
app/Models/ServiceAdsl.php
Normal file
20
app/Models/ServiceAdsl.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceAdsl extends Model
|
||||
{
|
||||
protected $table = 'ab_service__adsl';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->service_number;
|
||||
}
|
||||
}
|
25
app/Models/ServiceDomain.php
Normal file
25
app/Models/ServiceDomain.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceDomain extends Model
|
||||
{
|
||||
protected $table = 'ab_service__domain';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s.%s',$this->domain_name,$this->tld->name);
|
||||
}
|
||||
}
|
26
app/Models/ServiceSsl.php
Normal file
26
app/Models/ServiceSsl.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceSsl extends Model
|
||||
{
|
||||
protected $table = 'ab_service__ssl';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
// @todo Merge in SSL functions from old site
|
||||
return 'SSL';
|
||||
}
|
||||
}
|
@@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Site extends Model
|
||||
{
|
||||
protected $table = 'ab_setup';
|
||||
|
||||
protected $casts = [
|
||||
'address'=>'array',
|
||||
];
|
||||
@@ -24,7 +26,95 @@ class Site extends Model
|
||||
['title'=>'Project 4','description'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','subtitle'=>'Lorem ipsum dolor sit amet','image_small'=>'/image/generic/150/75/d00','image_large'=>'/image/generic/500/400/a00'],
|
||||
],
|
||||
'activity_intro'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
||||
'blockquote'=>[['title'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','image'=>'/image/generic/150/75/1A3AAA']],
|
||||
'block_quotes'=>[
|
||||
[
|
||||
'title'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
||||
'image'=>'/image/generic/150/75/1A3AAA'
|
||||
],
|
||||
],
|
||||
'clients'=>[
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/399',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/499',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/599',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/699',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/689',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/679',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/669',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/659',
|
||||
],
|
||||
[
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'hover'=>'/image/generic/200/100/649',
|
||||
],
|
||||
],
|
||||
'clients_intro'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore',
|
||||
'main_slider'=>[
|
||||
[
|
||||
'title'=>'Header <br/><span class="carousel-title-normal">and Title</span>',
|
||||
'text'=>'This is what you were looking for',
|
||||
'style'=>1,
|
||||
'image'=>'url(/image/generic/300/300/eee)',
|
||||
'button'=>['text'=>'Purchase Now','url'=>'#'],
|
||||
],
|
||||
[
|
||||
'title'=>'Header and Title',
|
||||
'text'=>'This is what you were looking for',
|
||||
'text2'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br/>Sed est nunc, sagittis at consectetur id.',
|
||||
'style'=>2,
|
||||
'image'=>'url(/image/generic/400/400/ddd)',
|
||||
'button'=>['text'=>'Purchase Now','url'=>'#'],
|
||||
],
|
||||
[
|
||||
'title'=>'Header and Title',
|
||||
'text'=>'This is what you were looking for',
|
||||
'text2'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br/>Sed est nunc, sagittis at consectetur id.',
|
||||
'style'=>2,
|
||||
'image'=>'url(/image/generic/500/500/eee)',
|
||||
//'button'=>['text'=>'Purchase Now','url'=>'#'],
|
||||
],
|
||||
],
|
||||
'page_tabs'=>[
|
||||
[
|
||||
'title'=>'Title 1',
|
||||
'image'=>'/image/generic/200/100/999',
|
||||
'text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua',
|
||||
|
||||
],
|
||||
[
|
||||
'title'=>'Title 2',
|
||||
'image'=>'/image/generic/200/100/799',
|
||||
'text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua',
|
||||
|
||||
],
|
||||
[
|
||||
'title'=>'Title 3',
|
||||
'image'=>'/image/generic/200/100/979',
|
||||
'text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua',
|
||||
],
|
||||
],
|
||||
'site'=>[
|
||||
'id'=>NULL,
|
||||
'address'=>json_decode('{"address1":"PO Box 149","address2":"7 Woodlands Court","city":"Bendigo","state":"VIC","postcode":"3550"}'),
|
||||
@@ -45,12 +135,38 @@ class Site extends Model
|
||||
['title'=>'Title 2','text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','icon'=>'fa fa-compress green','image'=>NULL],
|
||||
['title'=>'Title 3','text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','icon'=>'fa fa-check red','image'=>'/image/generic/200/100/999'],
|
||||
],
|
||||
'social'=>['facebook','linkedin','googleplus','twitter'],
|
||||
'social'=>[
|
||||
[
|
||||
'name'=>'facebook',
|
||||
'url'=>'http://www.facebook.com',
|
||||
],
|
||||
[
|
||||
'name'=>'linkedin',
|
||||
'url'=>'http://www.linkedin.com',
|
||||
],
|
||||
[ 'name'=>'twitter',
|
||||
'url'=>'http://www.twitter.com',
|
||||
],
|
||||
],
|
||||
'steps'=>[
|
||||
['title'=>'Title 1','description'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud'],
|
||||
['title'=>'Title 2','description'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud'],
|
||||
['title'=>'Title 3','description'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud'],
|
||||
],
|
||||
'testimonials'=>[
|
||||
[
|
||||
'title'=>'Title 1',
|
||||
'name'=>'Bart Simpson',
|
||||
'quote'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud',
|
||||
'photo'=>'/image/generic/200/100/999',
|
||||
],
|
||||
[
|
||||
'title'=>'Title 2',
|
||||
'name'=>'Lisa Simpson',
|
||||
'quote'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud',
|
||||
'photo'=>'/image/generic/200/100/499',
|
||||
],
|
||||
],
|
||||
'top_menu'=>[
|
||||
'Home'=>['name'=>'Home','url'=>'/','children'=>[
|
||||
['name'=>'Link 1','url'=>'#/l2', 'children'=>[]],
|
||||
@@ -65,6 +181,66 @@ class Site extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public function getActivitiesAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'activity');
|
||||
}
|
||||
|
||||
public function getActivityIntroAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'activity_intro');
|
||||
}
|
||||
|
||||
public function getClientsAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'clients');
|
||||
}
|
||||
|
||||
public function getCLientsIntoAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'clients_info');
|
||||
}
|
||||
|
||||
public function getServicesAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'services');
|
||||
}
|
||||
|
||||
public function getBlockQuotesAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'block_quotes');
|
||||
}
|
||||
|
||||
public function getPageTabsAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'page_tabs');
|
||||
}
|
||||
|
||||
public function getSiteSliderAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'main_slider');
|
||||
}
|
||||
|
||||
public function getSocialAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'social');
|
||||
}
|
||||
|
||||
public function getStepsAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'steps');
|
||||
}
|
||||
|
||||
public function getTestimonialsAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'testimonials');
|
||||
}
|
||||
|
||||
public function getTopMenuAttribute()
|
||||
{
|
||||
return array_get($this->_sampledata(),'top_menu');
|
||||
}
|
||||
|
||||
public function sample()
|
||||
{
|
||||
return $this->forceFill(array_get($this->_sampledata(),'site'));
|
||||
@@ -93,18 +269,6 @@ class Site extends Model
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function activity()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'activity');
|
||||
}
|
||||
|
||||
public function activity_intro()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'activity_intro');
|
||||
}
|
||||
|
||||
public function address($type='plain')
|
||||
{
|
||||
switch ($type)
|
||||
@@ -117,44 +281,12 @@ class Site extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function blockquote()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'blockquote');
|
||||
}
|
||||
|
||||
// @todo
|
||||
public function fax()
|
||||
{
|
||||
return '@todo';
|
||||
}
|
||||
|
||||
public function logo_url()
|
||||
{
|
||||
return url($this->logo ? $this->logo : '/image/generic/150/20/fff');
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'services');
|
||||
}
|
||||
|
||||
public function social()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'social');
|
||||
}
|
||||
|
||||
public function steps()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'steps');
|
||||
}
|
||||
|
||||
public function top_menu()
|
||||
{
|
||||
// @todo To be implemented
|
||||
return array_get($this->_sampledata(),'top_menu');
|
||||
}
|
||||
}
|
||||
|
62
app/User.php
62
app/User.php
@@ -7,6 +7,9 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
protected $table = 'ab_account';
|
||||
private $_currency;
|
||||
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
@@ -32,7 +35,33 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country');
|
||||
return $this->belongsTo(Models\Country::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* This users invoices
|
||||
*/
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Models\Invoice::class,'account_id');
|
||||
}
|
||||
|
||||
public function language()
|
||||
{
|
||||
return $this->belongsTo(Models\Language::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Models\Payment::class,'account_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* This users invoices
|
||||
*/
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Models\Service::class,'account_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,8 +75,35 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Return the user's full name
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->firstname.' '.$this->lastname;
|
||||
return $this->first_name.' '.$this->last_name;
|
||||
}
|
||||
|
||||
public function getInvoicesDueAttribute()
|
||||
{
|
||||
return $this->invoices
|
||||
->where('active',TRUE)
|
||||
->sortBy('id')
|
||||
->transform(function ($item) { if ($item->due) return $item; })
|
||||
->reverse()
|
||||
->filter();
|
||||
}
|
||||
|
||||
public function getPaymentHistoryAttribute()
|
||||
{
|
||||
return $this->payments
|
||||
->sortBy('date_payment')
|
||||
->reverse();
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->full_name;
|
||||
}
|
||||
|
||||
public function getServicesActiveAttribute()
|
||||
{
|
||||
return $this->services->where('active',TRUE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user