Changed SITE_SETUP to SITE, using ->address instead of ->address(), added email_log, is now in views

This commit is contained in:
Deon George 2021-07-02 09:12:34 +10:00
parent c34da6bfb8
commit 34139bcbc2
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
19 changed files with 124 additions and 144 deletions

View File

@ -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()

View File

@ -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') {

View File

@ -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();

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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()

View File

@ -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());
}
}
}

View File

@ -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',

View File

@ -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;

View File

@ -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;
}

6
composer.lock generated
View File

@ -2884,11 +2884,11 @@
},
{
"name": "leenooks/laravel",
"version": "9.0.5",
"version": "9.0.7",
"source": {
"type": "git",
"url": "https://dev.leenooks.net/leenooks/laravel",
"reference": "45be8553a29f1887273b10a56982f55134bfd9e0"
"reference": "1f114667aad9c023716516e19a292fbc0748f9a8"
},
"require": {
"creativeorange/gravatar": "^1.0",
@ -2925,7 +2925,7 @@
"laravel",
"leenooks"
],
"time": "2021-07-01T01:58:50+00:00"
"time": "2021-07-01T23:09:31+00:00"
},
{
"name": "monolog/monolog",

View File

@ -8,7 +8,7 @@
@endsection
@section('contentheader_title')
{{ $so->site_name }}
{{ $site->site_name }}
@endsection
@section('contentheader_description')
Setup
@ -36,7 +36,7 @@
<div class="col-12">
<div class="form-group has-validation">
<label for="site_name">Organisation Name</label>
<input type="text" class="form-control form-control-border @error('site_name') is-invalid @enderror" id="site_name" name="site_name" placeholder="Site Name..." value="{{ old('site_name',$so->site_name) }}" required>
<input type="text" class="form-control form-control-border @error('site_name') is-invalid @enderror" id="site_name" name="site_name" placeholder="Site Name..." value="{{ old('site_name',$site->site_name) }}" required>
<span class="invalid-feedback" role="alert">
@error('site_name')
{{ $message }}
@ -53,7 +53,7 @@
<div class="col-10">
<div class="form-group has-validation">
<label for="site_logo">Site Logo</label>
<input type="file" class="form-control @error('site_logo') is-invalid @enderror" id="site_logo" name="site_logo"><img class="col-12" src="{{ asset($so->site_logo) }}">
<input type="file" class="form-control @error('site_logo') is-invalid @enderror" id="site_logo" name="site_logo"><img class="col-12" src="{{ asset($site->site_logo) }}">
<span class="invalid-feedback" role="alert">
@error('site_logo')
{{ $message }}
@ -62,6 +62,20 @@
</div>
</div>
</div>
<div class="row">
<div class="col-10">
<div class="form-group has-validation">
<label for="email_logo">Email Logo</label>
<input type="file" class="form-control @error('email_logo') is-invalid @enderror" id="email_logo" name="email_logo"><img class="col-12" src="{{ asset($site->email_logo) }}">
<span class="invalid-feedback" role="alert">
@error('email_logo')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>
</div>
<div class="col-4">
@ -69,8 +83,8 @@
<div class="col-12">
<div class="form-group has-validation">
<label for="site_address1">Address Lines</label>
<input type="text" class="form-control form-control-border @error('site_address1') is-invalid @enderror" id="site_address1" name="site_address1" placeholder="Address1" value="{{ old('site_address1',$so->site_address1) }}" required>
<input type="text" class="form-control form-control-border" id="site_address2" name="site_address2" placeholder="Address2" value="{{ old('site_address2',$so->site_address2) }}">
<input type="text" class="form-control form-control-border @error('site_address1') is-invalid @enderror" id="site_address1" name="site_address1" placeholder="Address1" value="{{ old('site_address1',$site->site_address1) }}" required>
<input type="text" class="form-control form-control-border" id="site_address2" name="site_address2" placeholder="Address2" value="{{ old('site_address2',$site->site_address2) }}">
<span class="invalid-feedback" role="alert">
@error('site_address1')
{{ $message }}
@ -86,7 +100,7 @@
<div class="col-12">
<div class="form-group has-validation">
<label for="site_address">City</label>
<input type="text" class="form-control form-control-border @error('site_city') is-invalid @enderror" id="site_city" name="site_city" placeholder="City" value="{{ old('site_city',$so->site_city) }}">
<input type="text" class="form-control form-control-border @error('site_city') is-invalid @enderror" id="site_city" name="site_city" placeholder="City" value="{{ old('site_city',$site->site_city) }}">
<span class="invalid-feedback" role="alert">
@error('site_city')
{{ $message }}
@ -102,7 +116,7 @@
<div class="col-12" style="display: inline-flex;">
<div class="form-group has-validation">
<label for="site_address">State</label>
<input type="text" class="form-control form-control-border @error('site_state') is-invalid @enderror col-5" id="site_state" name="site_state" placeholder="State" value="{{ old('site_state',$so->site_state) }}">
<input type="text" class="form-control form-control-border @error('site_state') is-invalid @enderror col-5" id="site_state" name="site_state" placeholder="State" value="{{ old('site_state',$site->site_state) }}">
<span class="invalid-feedback" role="alert">
@error('site_state')
{{ $message }}
@ -114,7 +128,7 @@
<div class="form-group has-validation">
<label for="site_address">Postal Code</label>
<input type="text" class="form-control form-control-border @error('site_postcode') is-invalid @enderror col-5" id="site_postcode" name="site_postcode" placeholder="Postal Code" value="{{ old('site_postcode',$so->site_postcode) }}">
<input type="text" class="form-control form-control-border @error('site_postcode') is-invalid @enderror col-5" id="site_postcode" name="site_postcode" placeholder="Postal Code" value="{{ old('site_postcode',$site->site_postcode) }}">
<span class="invalid-feedback" role="alert">
@error('site_postcode')
{{ $message }}
@ -130,7 +144,7 @@
<div class="col-4">
<div class="form-group has-validation">
<label for="site_phone">Phone</label>
<input type="text" class="form-control form-control-border @error('site_phone') is-invalid @enderror" id="site_phone" name="site_phone" placeholder="Site Phone" value="{{ old('site_phone',$so->site_phone) }}">
<input type="text" class="form-control form-control-border @error('site_phone') is-invalid @enderror" id="site_phone" name="site_phone" placeholder="Site Phone" value="{{ old('site_phone',$site->site_phone) }}">
<span class="invalid-feedback" role="alert">
@error('site_phone')
{{ $message }}
@ -140,7 +154,7 @@
<div class="form-group has-validation">
<label for="site_fax">Fax</label>
<input type="text" class="form-control form-control-border @error('site_fax') is-invalid @enderror" id="site_fax" name="site_fax" placeholder="Site Fax" value="{{ old('site_fax',$so->site_fax) }}">
<input type="text" class="form-control form-control-border @error('site_fax') is-invalid @enderror" id="site_fax" name="site_fax" placeholder="Site Fax" value="{{ old('site_fax',$site->site_fax) }}">
<span class="invalid-feedback" role="alert">
@error('site_fax')
{{ $message }}
@ -150,7 +164,7 @@
<div class="form-group has-validation">
<label for="site_email">Email</label>
<input type="email" class="form-control form-control-border @error('site_email') is-invalid @enderror" id="site_email" name="site_email" placeholder="Site Email" value="{{ old('site_email',$so->site_email) }}" required>
<input type="email" class="form-control form-control-border @error('site_email') is-invalid @enderror" id="site_email" name="site_email" placeholder="Site Email" value="{{ old('site_email',$site->site_email) }}" required>
<span class="invalid-feedback" role="alert">
@error('site_email')
{{ $message }}
@ -163,7 +177,7 @@
<div class="form-group has-validation">
<label for="site_tax">Tax Number</label>
<span class="input-group-prepend">ABN</span>
<input type="text" class="form-control form-control-border @error('site_tax') is-invalid @enderror" id="site_tax" name="site_tax" placeholder="Site Tax" value="{{ old('site_tax',$so->site_tax) }}" required>
<input type="text" class="form-control form-control-border @error('site_tax') is-invalid @enderror" id="site_tax" name="site_tax" placeholder="Site Tax" value="{{ old('site_tax',$site->site_tax) }}" required>
<span class="invalid-feedback" role="alert">
@error('site_tax')
{{ $message }}
@ -177,7 +191,7 @@
<div class="col-12">
<div class="form-group has-validation">
<label for="site_description">Organisation Description</label>
<textarea class="form-control @error('site_description') is-invalid @enderror" id="site_description" name="site_description" placeholder="Site Description...">{{ old('site_description',$so->site_description) }}</textarea>
<textarea class="form-control @error('site_description') is-invalid @enderror" id="site_description" name="site_description" placeholder="Site Description...">{{ old('site_description',$site->site_description) }}</textarea>
<span class="input-helper">Brief description of site.</span>
<span class="invalid-feedback" role="alert">
@error('site_description')
@ -192,7 +206,7 @@
<div class="col-12">
<a href="{{ url('/') }}" class="btn btn-danger">Cancel</a>
@can('wholesaler')
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($so->exists)Save @else Add @endif</button>
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($site->exists)Save @else Add @endif</button>
@endcan
</div>
</div>

View File

@ -20,7 +20,7 @@
<div class="row">
<div class="col-8">
<h2>
<img src="{{ $so->site_logo }}">
<img src="{{ $site->site_logo }}">
</h2>
</div>
@ -35,11 +35,11 @@
<div class="col-4 invoice-col">
FROM:
<address>
<strong>{{ $so->site_name }}</strong><br>
{!! $so->address('html') !!}<br>
<strong>{{ $site->site_name }}</strong><br>
{!! join('<br>',$site->address) !!}
<br>
<strong>Email:</strong> {{ $so->site_email }}<br>
<strong>Phone:</strong> {{ $so->site_phone }}
<strong>Email:</strong> {{ $site->site_email }}<br>
<strong>Phone:</strong> {{ $site->site_phone }}
</address>
</div>
@ -47,7 +47,7 @@
TO:
<address>
<strong>{{ $o->account->company }}</strong><br>
{!! $o->account->address('html') !!}<br>
{!! join('<br>',$o->account->address) !!}
<br>
<strong>Email:</strong> {{ $o->account->email }}<br>
@if ($o->account->phone)

View File

@ -4,14 +4,14 @@
<div class="row margin-bottom-40 our-clients">
<div class="col-md-3">
<h2><a href="javascript:;">Our Clients</a></h2>
<p>{{ $so->clients_intro }}</p>
<p>{{ $site->clients_intro }}</p>
</div>
{{-- @todo make sure this scrolls --}}
<div class="col-md-9">
<div class="owl-carousel owl-carousel6-brands">
@foreach($so->clients as $c)
@foreach($site->clients as $c)
<div class="client-item">
<a href="javascript:;">
<img src="{{ $c['image'] }}" class="img-responsive" alt="">

View File

@ -2,14 +2,14 @@
<div class="col-md-7 tab-style-1">
<ul class="nav nav-tabs">
@php($c=0)
@foreach ($so->page_tabs as $o)
@foreach ($site->page_tabs as $o)
<li @if(! $c++) class="active" @endif><a href="#tab-{{ $c }}" data-toggle="tab">{{ $o['title'] }}</a></li>
@endforeach
</ul>
<div class="tab-content">
@php($c=0)
@foreach ($so->page_tabs as $o)
@foreach ($site->page_tabs as $o)
<div class="tab-pane row fade in @if(! $c++) active @endif" id="tab-{{ $c }}">
<div class="col-md-3 col-sm-3">
<a href="{{ $o['image'] }}" class="fancybox-button" title="{{ $o['title'] }}" data-rel="fancybox-button">

View File

@ -4,7 +4,7 @@
<!-- Carousel items -->
<div class="carousel-inner">
@php($c=0)
@foreach($so->testimonials as $o)
@foreach($site->testimonials as $o)
<div class="item @if(! $c++) active @endif">
<blockquote><p>{{ $o['quote'] }}</p></blockquote>
<div class="carousel-info">

View File

@ -1,31 +1,31 @@
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header',['site'=>$site])
{{ $heading }}
@endcomponent
@endslot
{{-- Header --}}
@slot('header')
@component('mail::header',['site'=>$site])
{{ $heading }}
@endcomponent
@endslot
{{-- Body --}}
{{ $slot }}
{{-- Body --}}
{{ $slot }}
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
<div class="fixedw" style="text-align: right; font-size: 0.8em;">
{{ config('mail.from.name') }}<br>
{!! $site->address('html') !!}<br>
{{ $site->site_email }}
</div>
@endcomponent
@endslot
@endcomponent
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
<div class="fixedw" style="text-align: right; font-size: 0.8em;">
{{ config('mail.from.name') }}<br>
{!! join('<br>',$site->address) !!}<br>
{{ $site->site_email }}
</div>
@endcomponent
@endslot
@endcomponent

View File

@ -4,6 +4,7 @@ use App\Http\Controllers\{AdminController,
Auth\LoginController,
CheckoutController,
HomeController,
MediaController,
PaypalController,
WelcomeController};
@ -29,7 +30,7 @@ Route::group(['middleware'=>['theme:adminlte-be']],function() {
});
// Generic Image Renderer - Render images that we dont have with a generic image
Route::get('image/generic/{width}/{height}/{color}/{name?}','MediaController@image')->name('image');
Route::get('image/generic/{width}/{height}/{color}/{name?}',[MediaController::class,'image'])->name('image');
// Our Admin Routes
Route::group(['middleware'=>['theme:adminlte-be','auth','role:wholesaler'],'prefix'=>'a'],function() {