Changed SITE_SETUP to SITE, using ->address instead of ->address(), added email_log, is now in views
This commit is contained in:
@@ -5,7 +5,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Models\{Service,SiteDetails};
|
||||
use App\Models\{Service,SiteDetail};
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
@@ -39,9 +39,10 @@ class AdminController extends Controller
|
||||
'social' => 'nullable|array',
|
||||
'top_menu' => 'nullable|array',
|
||||
'site_logo' => 'nullable|image',
|
||||
'email_logo' => 'nullable|image',
|
||||
]);
|
||||
|
||||
$so = config('SITE_SETUP');
|
||||
$site = config('SITE');
|
||||
|
||||
// @todo - not currently rendered in the home page
|
||||
$validated['social'] = [];
|
||||
@@ -50,9 +51,9 @@ class AdminController extends Controller
|
||||
// Handle the images
|
||||
foreach(['site_logo','email_logo'] as $key)
|
||||
if (array_key_exists($key,$validated))
|
||||
$validated[$key] = ($x=$validated[$key])->storeAs('site/'.config('SITE_SETUP')->site_id,$x->getClientOriginalName(),'public');
|
||||
$validated[$key] = ($x=$validated[$key])->storeAs('site/'.$site->site_id,$x->getClientOriginalName(),'public');
|
||||
|
||||
foreach ($so->details as $oo)
|
||||
foreach ($site->details as $oo)
|
||||
if (array_key_exists($oo->key,$validated)) {
|
||||
$oo->value = Arr::get($validated,$oo->key);
|
||||
$oo->save();
|
||||
@@ -62,11 +63,11 @@ class AdminController extends Controller
|
||||
|
||||
// Left over values to be created.
|
||||
foreach ($validated as $k=>$v) {
|
||||
$oo = new SiteDetails;
|
||||
$oo = new SiteDetail;
|
||||
$oo->key = $k;
|
||||
$oo->value = $v ?: '';
|
||||
|
||||
$so->details()->save($oo);
|
||||
$site->details()->save($oo);
|
||||
}
|
||||
|
||||
return redirect()->back()
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use Image;
|
||||
|
||||
class MediaController extends Controller
|
||||
@@ -10,8 +9,9 @@ class MediaController extends Controller
|
||||
/**
|
||||
* Create a generic image
|
||||
*
|
||||
* @param $width
|
||||
* @param $height
|
||||
* @param $width
|
||||
* @param $height
|
||||
* @param string $color
|
||||
* @return mixed
|
||||
*/
|
||||
public function image($width,$height,$color='#ccc') {
|
||||
|
@@ -71,11 +71,11 @@ class OrderController extends Controller
|
||||
if (! $uo->exists)
|
||||
{
|
||||
// @todo Make this automatic
|
||||
$uo->site_id = config('SITE_SETUP')->id;
|
||||
$uo->site_id = config('SITE')->id;
|
||||
$uo->active = FALSE;
|
||||
$uo->firstname = '';
|
||||
$uo->lastname = '';
|
||||
$uo->country_id = config('SITE_SETUP')->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->active = 1;
|
||||
$uo->save();
|
||||
@@ -88,10 +88,10 @@ class OrderController extends Controller
|
||||
$ao = new Account;
|
||||
//$ao->id = Account::NextId();
|
||||
// @todo Make this automatic
|
||||
$ao->site_id = config('SITE_SETUP')->id;
|
||||
$ao->country_id = config('SITE_SETUP')->country_id; // @todo This might be wrong
|
||||
$ao->language_id = config('SITE_SETUP')->language_id; // @todo This might be wrong
|
||||
$ao->currency_id = config('SITE_SETUP')->currency_id; // @todo This might be wrong
|
||||
$ao->site_id = config('SITE')->id;
|
||||
$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->currency_id = config('SITE')->currency_id; // @todo This might be wrong
|
||||
$ao->active = 1;
|
||||
$uo->accounts()->save($ao);
|
||||
|
||||
@@ -102,7 +102,7 @@ class OrderController extends Controller
|
||||
$so = new Service;
|
||||
|
||||
// @todo Make this automatic
|
||||
$so->site_id = config('SITE_SETUP')->id;
|
||||
$so->site_id = config('SITE')->id;
|
||||
$so->product_id = $request->input('product_id');
|
||||
$so->order_status = 'ORDER-SUBMIT';
|
||||
$so->orderby_id = Auth::id();
|
||||
|
@@ -43,9 +43,9 @@ class SetSite
|
||||
}
|
||||
|
||||
// Set who we are in SETUP.
|
||||
Config::set('SITE_SETUP',$so);
|
||||
Config::set('SITE',$so);
|
||||
if (! $request->ajax())
|
||||
View::share('so',$so);
|
||||
View::share('site',$so);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@@ -149,6 +149,20 @@ class Account extends Model implements IDs
|
||||
return $this->getUrlAdminAttribute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the address for the account
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAddressAttribute(): array
|
||||
{
|
||||
return [
|
||||
$this->address1,
|
||||
$this->address2,
|
||||
sprintf('%s %s %s',$this->city.(($this->state OR $this->zip) ? ',' : ''),$this->state,$this->zip)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Account Unique Identifier
|
||||
* @return string
|
||||
@@ -219,36 +233,7 @@ class Account extends Model implements IDs
|
||||
return sprintf('<a href="/u/account/view/%s">%s</a>',$this->id,$this->account_id);
|
||||
}
|
||||
|
||||
/** FUNCTIONS **/
|
||||
|
||||
private function _address()
|
||||
{
|
||||
$return = [];
|
||||
|
||||
if ($this->address1)
|
||||
array_push($return,$this->address1);
|
||||
if ($this->address2)
|
||||
array_push($return,$this->address2);
|
||||
if ($this->city)
|
||||
array_push($return,sprintf('%s %s %s',$this->city.(($this->state OR $this->zip) ? ',' : ''),$this->state,$this->zip));
|
||||
|
||||
if (! $return)
|
||||
$return = ['No Address'];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function address($type='plain')
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 'html' : return join('<br>',$this->_address());
|
||||
case 'newline': return join("\m",$this->_address());
|
||||
|
||||
default:
|
||||
return join("\n",$this->_address());
|
||||
}
|
||||
}
|
||||
/* GENERAL METHODS */
|
||||
|
||||
/**
|
||||
* Get the due invoices on an account
|
||||
|
@@ -139,7 +139,7 @@ class Invoice extends Model implements IDs
|
||||
// @todo Move this to a site configuration
|
||||
public function getInvoiceTextAttribute()
|
||||
{
|
||||
return sprintf('Thank you for using %s for your Internet Services.',config('SITE_SETUP')->site_name);
|
||||
return sprintf('Thank you for using %s for your Internet Services.',config('SITE')->site_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -100,7 +100,7 @@ class Product extends Model implements IDs
|
||||
|
||||
private function getDefaultLanguage()
|
||||
{
|
||||
return config('SITE_SETUP')->language;
|
||||
return config('SITE')->language;
|
||||
}
|
||||
|
||||
public function getDescriptionAttribute()
|
||||
|
@@ -31,7 +31,7 @@ class Site extends Model
|
||||
|
||||
public function details()
|
||||
{
|
||||
return $this->hasMany(SiteDetails::class,NULL,'site_id');
|
||||
return $this->hasMany(SiteDetail::class,NULL,'site_id');
|
||||
}
|
||||
|
||||
public function language()
|
||||
@@ -60,7 +60,7 @@ class Site extends Model
|
||||
return $x;
|
||||
|
||||
if (is_null($details))
|
||||
$details = new SiteDetails;
|
||||
$details = new SiteDetail;
|
||||
|
||||
// Get a default value for this key
|
||||
$value = $details->sample($key);
|
||||
@@ -88,6 +88,15 @@ class Site extends Model
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function getAddressAttribute(): array
|
||||
{
|
||||
return [
|
||||
$this->site_address1,
|
||||
$this->site_address2,
|
||||
sprintf('%s %s %s',$this->site_city.(($this->site_state OR $this->site_postcode) ? ',' : ''),$this->site_state,$this->site_postcode)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the path to the mail logo, so it can be displayed.
|
||||
*
|
||||
@@ -108,35 +117,4 @@ class Site extends Model
|
||||
{
|
||||
return (($x=$this->detail_item('site_logo')) !== NULL) ? '/storage/'.$x : '/image/generic/150/20/fff';
|
||||
}
|
||||
|
||||
// @todo - To optimize
|
||||
private function _address()
|
||||
{
|
||||
$return = [];
|
||||
|
||||
if ($this->site_address1)
|
||||
array_push($return,$this->site_address1);
|
||||
if ($this->site_address2)
|
||||
array_push($return,$this->site_address2);
|
||||
if ($this->site_city)
|
||||
array_push($return,sprintf('%s %s %s',$this->site_city.(($this->site_state OR $this->site_postcode) ? ',' : ''),$this->site_state,$this->site_postcode));
|
||||
|
||||
if (! $return)
|
||||
$return = ['No Address'];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// @todo - To optimize
|
||||
public function address($type='plain')
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 'html' : return join('<br>',$this->_address());
|
||||
case 'newline': return join("\m",$this->_address());
|
||||
|
||||
default:
|
||||
return join("\n",$this->_address());
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Leenooks\Traits\CompositeKeys;
|
||||
|
||||
class SiteDetails extends Model
|
||||
class SiteDetail extends Model
|
||||
{
|
||||
use CompositeKeys;
|
||||
|
||||
@@ -189,6 +189,7 @@ class SiteDetails extends Model
|
||||
['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'],
|
||||
],
|
||||
*/
|
||||
'email_logo'=>route('image',['width'=>150,'height'=>20,'color'=>'eee']),
|
||||
'site_address1' => 'Address line 1',
|
||||
'site_address2' => 'Address line 2',
|
||||
'site_description'=>'Example Site',
|
@@ -23,7 +23,7 @@ trait NextKey
|
||||
$model->id = self::NextId();
|
||||
|
||||
if (! $model->site_id)
|
||||
$model->site_id = config('SITE_SETUP')->id;
|
||||
$model->site_id = config('SITE')->id;
|
||||
});
|
||||
|
||||
static::saved(function($model)
|
||||
@@ -40,14 +40,14 @@ trait NextKey
|
||||
|
||||
$mo = new Module;
|
||||
$mo->name = $model::RECORD_ID;
|
||||
$mo->site_id = $model->site_id ?: config('SITE_SETUP')->id;
|
||||
$mo->site_id = $model->site_id ?: config('SITE')->id;
|
||||
$mo->save();
|
||||
}
|
||||
|
||||
if (! $mo->record) {
|
||||
$mo->record = new Record;
|
||||
$mo->record->module_id = $mo->id;
|
||||
$mo->record->site_id = $model->site_id ?: config('SITE_SETUP')->id;
|
||||
$mo->record->site_id = $model->site_id ?: config('SITE')->id;
|
||||
}
|
||||
|
||||
$mo->record->id = $model->id;
|
||||
|
@@ -43,7 +43,7 @@ trait OrderServiceOptions
|
||||
$o->forceFill(array_undot($x));
|
||||
|
||||
// @todo Make this automatic
|
||||
$o->site_id = config('SITE_SETUP')->id;
|
||||
$o->site_id = config('SITE')->id;
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
Reference in New Issue
Block a user