Site related updates
This commit is contained in:
parent
8d194c5523
commit
b7b6a575bc
@ -31,7 +31,7 @@ class AdminController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (! $o->exists) {
|
if (! $o->exists) {
|
||||||
$o->site_id = config('SITE')->site_id;
|
$o->site_id = config('site')->site_id;
|
||||||
$o->user_id = Auth::id();
|
$o->user_id = Auth::id();
|
||||||
$o->active = TRUE;
|
$o->active = TRUE;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
if (! $o->exists) {
|
if (! $o->exists) {
|
||||||
$o->forceFill($request->only(['account_id','payment_date','checkout_id','checkout_id','total_amt','fees_amt','source_id','pending','notes','ip']));
|
$o->forceFill($request->only(['account_id','payment_date','checkout_id','checkout_id','total_amt','fees_amt','source_id','pending','notes','ip']));
|
||||||
$o->site_id = config('SITE')->site_id;
|
$o->site_id = config('site')->site_id;
|
||||||
$o->save();
|
$o->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class AdminController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$oo->alloc_amt = ($oo->invoice->due >= 0) && ($oo->invoice->due-$amount >= 0) ? $amount : 0;
|
$oo->alloc_amt = ($oo->invoice->due >= 0) && ($oo->invoice->due-$amount >= 0) ? $amount : 0;
|
||||||
$oo->site_id = config('SITE')->site_id;
|
$oo->site_id = config('site')->site_id;
|
||||||
$o->items()->save($oo);
|
$o->items()->save($oo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ class AdminController extends Controller
|
|||||||
'email_logo' => 'nullable|image',
|
'email_logo' => 'nullable|image',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$site = config('SITE');
|
$site = config('site');
|
||||||
|
|
||||||
// @todo - not currently rendered in the home page
|
// @todo - not currently rendered in the home page
|
||||||
$validated['social'] = [];
|
$validated['social'] = [];
|
||||||
|
@ -46,7 +46,7 @@ class LoginController extends Controller
|
|||||||
{
|
{
|
||||||
$this->validateLogin($request);
|
$this->validateLogin($request);
|
||||||
|
|
||||||
if (Auth::attempt(array_merge($this->credentials($request),['active'=>TRUE,'site_id'=>config('site')->site_id]))) {
|
if (Auth::attempt(array_merge($this->credentials($request),['active'=>TRUE]))) {
|
||||||
$request->session()->regenerate();
|
$request->session()->regenerate();
|
||||||
|
|
||||||
return $this->sendLoginResponse($request);
|
return $this->sendLoginResponse($request);
|
||||||
|
@ -67,11 +67,11 @@ class OrderController extends Controller
|
|||||||
// If this is a new client
|
// If this is a new client
|
||||||
if (! $uo->exists) {
|
if (! $uo->exists) {
|
||||||
// @todo Make this automatic
|
// @todo Make this automatic
|
||||||
$uo->site_id = config('SITE')->site_id;
|
$uo->site_id = config('site')->site_id;
|
||||||
$uo->active = FALSE;
|
$uo->active = FALSE;
|
||||||
$uo->firstname = '';
|
$uo->firstname = '';
|
||||||
$uo->lastname = '';
|
$uo->lastname = '';
|
||||||
$uo->country_id = config('SITE')->country_id; // @todo This might be wrong
|
$uo->country_id = config('site')->country_id; // @todo This might be wrong
|
||||||
$uo->parent_id = Auth::id() ?: 1; // @todo This should be configured to a default user
|
$uo->parent_id = Auth::id() ?: 1; // @todo This should be configured to a default user
|
||||||
$uo->active = 1;
|
$uo->active = 1;
|
||||||
$uo->save();
|
$uo->save();
|
||||||
@ -83,10 +83,10 @@ class OrderController extends Controller
|
|||||||
$ao = new Account;
|
$ao = new Account;
|
||||||
//$ao->id = Account::NextId();
|
//$ao->id = Account::NextId();
|
||||||
// @todo Make this automatic
|
// @todo Make this automatic
|
||||||
$ao->site_id = config('SITE')->site_id;
|
$ao->site_id = config('site')->site_id;
|
||||||
$ao->country_id = config('SITE')->country_id; // @todo This might be wrong
|
$ao->country_id = config('site')->country_id; // @todo This might be wrong
|
||||||
$ao->language_id = config('SITE')->language_id; // @todo This might be wrong
|
$ao->language_id = config('site')->language_id; // @todo This might be wrong
|
||||||
$ao->currency_id = config('SITE')->currency_id; // @todo This might be wrong
|
$ao->currency_id = config('site')->currency_id; // @todo This might be wrong
|
||||||
$ao->active = 1;
|
$ao->active = 1;
|
||||||
$uo->accounts()->save($ao);
|
$uo->accounts()->save($ao);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class OrderController extends Controller
|
|||||||
$so = new Service;
|
$so = new Service;
|
||||||
|
|
||||||
// @todo Make this automatic
|
// @todo Make this automatic
|
||||||
$so->site_id = config('SITE')->site_id;
|
$so->site_id = config('site')->site_id;
|
||||||
$so->product_id = $request->input('product_id');
|
$so->product_id = $request->input('product_id');
|
||||||
$so->order_status = 'ORDER-SUBMIT';
|
$so->order_status = 'ORDER-SUBMIT';
|
||||||
$so->orderby_id = Auth::id();
|
$so->orderby_id = Auth::id();
|
||||||
|
@ -141,7 +141,7 @@ class Invoice extends Model implements IDs
|
|||||||
// @todo Move this to a site configuration
|
// @todo Move this to a site configuration
|
||||||
public function getInvoiceTextAttribute()
|
public function getInvoiceTextAttribute()
|
||||||
{
|
{
|
||||||
return sprintf('Thank you for using %s for your Internet Services.',config('SITE')->site_name);
|
return sprintf('Thank you for using %s for your Internet Services.',config('site')->site_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
22
app/Models/Scopes/SiteScope.php
Normal file
22
app/Models/Scopes/SiteScope.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Scopes;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Scope;
|
||||||
|
|
||||||
|
class SiteScope implements Scope
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Apply the scope to a given Eloquent query builder.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||||
|
* @param \Illuminate\Database\Eloquent\Model $model
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function apply(Builder $builder, Model $model)
|
||||||
|
{
|
||||||
|
$builder->where($model->getTable().'.site_id',config('site')->site_id);
|
||||||
|
}
|
||||||
|
}
|
@ -14,10 +14,11 @@ use Leenooks\Traits\UserSwitch;
|
|||||||
use Spinen\QuickBooks\HasQuickBooksToken;
|
use Spinen\QuickBooks\HasQuickBooksToken;
|
||||||
|
|
||||||
use App\Notifications\ResetPassword as ResetPasswordNotification;
|
use App\Notifications\ResetPassword as ResetPasswordNotification;
|
||||||
|
use App\Traits\SiteID;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use HasApiTokens,Notifiable,UserSwitch,HasQuickBooksToken;
|
use HasApiTokens,Notifiable,UserSwitch,HasQuickBooksToken,SiteID;
|
||||||
|
|
||||||
protected $appends = [
|
protected $appends = [
|
||||||
'active_display',
|
'active_display',
|
||||||
|
@ -23,7 +23,7 @@ trait NextKey
|
|||||||
$model->id = self::NextId();
|
$model->id = self::NextId();
|
||||||
|
|
||||||
if (! $model->site_id)
|
if (! $model->site_id)
|
||||||
$model->site_id = config('SITE')->site_id;
|
$model->site_id = config('site')->site_id;
|
||||||
});
|
});
|
||||||
|
|
||||||
static::saved(function($model)
|
static::saved(function($model)
|
||||||
@ -41,14 +41,14 @@ trait NextKey
|
|||||||
|
|
||||||
$mo = new Module;
|
$mo = new Module;
|
||||||
$mo->name = $model::RECORD_ID;
|
$mo->name = $model::RECORD_ID;
|
||||||
$mo->site_id = $model->site_id ?: config('SITE')->site_id;
|
$mo->site_id = $model->site_id ?: config('site')->site_id;
|
||||||
$mo->save();
|
$mo->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $mo->record) {
|
if (! $mo->record) {
|
||||||
$mo->record = new Record;
|
$mo->record = new Record;
|
||||||
$mo->record->module_id = $mo->id;
|
$mo->record->module_id = $mo->id;
|
||||||
$mo->record->site_id = $model->site_id ?: config('SITE')->site_id;
|
$mo->record->site_id = $model->site_id ?: config('site')->site_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mo->record->id = $model->id;
|
$mo->record->id = $model->id;
|
||||||
|
@ -39,7 +39,7 @@ trait OrderServiceOptions
|
|||||||
$o->forceFill(array_undot($x));
|
$o->forceFill(array_undot($x));
|
||||||
|
|
||||||
// @todo Make this automatic
|
// @todo Make this automatic
|
||||||
$o->site_id = config('SITE')->site_id;
|
$o->site_id = config('site')->site_id;
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
29
app/Traits/SiteID.php
Normal file
29
app/Traits/SiteID.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures we retrieve and save models with the correct site_id
|
||||||
|
*/
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
use App\Models\Scopes\SiteScope;
|
||||||
|
|
||||||
|
trait SiteID
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This model is site scoped
|
||||||
|
*/
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
static::addGlobalScope(new SiteScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(array $options = [])
|
||||||
|
{
|
||||||
|
if (! Arr::get($this->attributes,'site_id'))
|
||||||
|
$this->site_id = config('site')->site_id;
|
||||||
|
|
||||||
|
return parent::save();
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@
|
|||||||
{{ $site->site_name }}
|
{{ $site->site_name }}
|
||||||
@endsection
|
@endsection
|
||||||
@section('contentheader_description')
|
@section('contentheader_description')
|
||||||
Setup
|
Setup #{{ $site->site_id }}
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('main-content')
|
@section('main-content')
|
||||||
|
Loading…
Reference in New Issue
Block a user