diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
new file mode 100644
index 0000000..5889c64
--- /dev/null
+++ b/app/Http/Controllers/AdminController.php
@@ -0,0 +1,78 @@
+$o]);
+ }
+
+ /**
+ * Site setup
+ *
+ * @note This method is protected by the routes
+ * @param Request $request
+ * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
+ */
+ public function setup(Request $request)
+ {
+ if ($request->post()) {
+ $validated = $request->validate([
+ 'site_name' => 'required|string|max:255',
+ 'site_email' => 'required|string|email|max:255',
+ 'site_address1' => 'required|string|max:255',
+ 'site_address2' => 'nullable|string|max:255',
+ 'site_city' => 'required|string|max:64',
+ 'site_state' => 'required|string|max:32',
+ 'site_postcode' => 'required|string|max:8',
+ 'site_description' => 'nullable|string|min:5',
+ 'site_phone' => 'nullable|regex:/[0-9 ]+/|min:6|max:12',
+ 'site_fax' => 'nullable|regex:/[0-9 ]+/|min:6|max:12',
+ 'site_tax' => 'required|regex:/[0-9 ]+/|size:14',
+ 'social' => 'nullable|array',
+ 'top_menu' => 'nullable|array',
+ 'site_logo' => 'nullable|image',
+ ]);
+
+ $so = config('SITE_SETUP');
+
+ // @todo - not currently rendered in the home page
+ $validated['social'] = [];
+ $validated['top_menu'] = [];
+
+ // 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');
+
+ foreach ($so->details as $oo)
+ if (array_key_exists($oo->key,$validated)) {
+ $oo->value = Arr::get($validated,$oo->key);
+ $oo->save();
+
+ unset($validated[$oo->key]);
+ }
+
+ // Left over values to be created.
+ foreach ($validated as $k=>$v) {
+ $oo = new SiteDetails;
+ $oo->key = $k;
+ $oo->value = $v ?: '';
+
+ $so->details()->save($oo);
+ }
+
+ return redirect()->back()
+ ->with('success','Settings saved');
+ }
+
+ return view('a.setup');
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/AdminHomeController.php b/app/Http/Controllers/AdminHomeController.php
deleted file mode 100644
index f5ff194..0000000
--- a/app/Http/Controllers/AdminHomeController.php
+++ /dev/null
@@ -1,82 +0,0 @@
-$o]);
- }
-
- public function setup()
- {
- return view('a.setup');
- }
-
- public function setup_update(Request $request)
- {
- $request->validate([
- 'site_name' => 'required|string|max:255',
- 'site_email' => 'required|string|email|max:255',
- 'site_address1' => 'required|string|max:255',
- 'site_address2' => 'nullable|string|max:255',
- 'site_city' => 'required|string|max:64',
- 'site_state' => 'required|string|max:32',
- 'site_postcode' => 'required|string|max:8',
- 'site_phone' => 'nullable|regex:/[0-9 ]+/|min:6|max:12',
- 'site_fax' => 'nullable|regex:/[0-9 ]+/|min:6|max:12',
- ]);
-
- // If we are more input that sample data, reject the update.
- if (config('SITE_SETUP')->allowed_keys(array_keys($request->except('_token'))))
- return redirect()->back()
- ->withInput()
- ->withErrors('Invalid configuration - values not expected.');
-
- foreach ($request->except('_token') as $key => $value)
- {
- if (! $value) {
- SiteDetails::where('site_id',config('SITE_SETUP')->id)->where('key',$key)->delete();
-
- } else {
- try {
- if ($key == 'site_logo' AND $value instanceof UploadedFile)
- {
- $path = $value->storeAs('site/'.config('SITE_SETUP')->id,$value->getClientOriginalName(),'public');
-
- SiteDetails::updateOrCreate([
- 'site_id'=>config('SITE_SETUP')->id,
- 'key'=>$key,
- ],[
- 'value'=>$path,
- ]);
-
- } else {
- // Update or create our config record.
- SiteDetails::updateOrCreate([
- 'site_id'=>config('SITE_SETUP')->id,
- 'key'=>$key,
- ],[
- 'value'=>$value,
- ]);
- }
-
- } catch (\Exception $e) {
- Log::debug($e->getMessage(),['k'=>$key,'v'=>$value]);
- }
- }
- }
-
- return redirect()->back()
- ->with('success','Setup Updated!');;
- }
-}
\ No newline at end of file
diff --git a/app/Http/Middleware/SetSite.php b/app/Http/Middleware/SetSite.php
index 9eafb0e..a041138 100644
--- a/app/Http/Middleware/SetSite.php
+++ b/app/Http/Middleware/SetSite.php
@@ -26,19 +26,26 @@ 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 = new Site;
if ($so->getTable() AND Schema::hasTable($so->getTable()))
- $so = Site::where('url',$request->root())->first();
+ $so = Site::where('url',$request->root())->single();
+
+ if ($so && ! $so->active)
+ abort(404);
// If we dont exist, we'll return a fake model.
- if ((! $so) || (! $so->exists))
- $so = (new Site)->sample();
+ if (! $so) {
+ if ($request->ajax())
+ abort(404);
+
+ $so = (new Site);
+ }
// Set who we are in SETUP.
Config::set('SITE_SETUP',$so);
- View::share('so',$so);
+ if (! $request->ajax())
+ View::share('so',$so);
return $next($request);
}
diff --git a/app/Models/Site.php b/app/Models/Site.php
index 6542b31..0b586d2 100644
--- a/app/Models/Site.php
+++ b/app/Models/Site.php
@@ -4,26 +4,34 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
-use Illuminate\Support\Arr;
+use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
class Site extends Model
{
use HasFactory;
- protected $table = 'ab_setup';
public $timestamps = FALSE;
- public $incrementing = FALSE;
-
- protected $with = ['details','language'];
protected $casts = [
'address'=>'array',
];
+ /* RELATIONS */
+
+ public function country()
+ {
+ return $this->belongsTo(Country::class);
+ }
+
+ public function currency()
+ {
+ return $this->belongsTo(Currency::class);
+ }
+
public function details()
{
- return $this->hasMany(SiteDetails::class);
+ return $this->hasMany(SiteDetails::class,NULL,'site_id');
}
public function language()
@@ -31,258 +39,77 @@ class Site extends Model
return $this->belongsTo(Language::class);
}
+ /* ATTRIBUTES */
+
+ public function getAllowedKeysAttribute(): Collection
+ {
+ return $this->_sampledata()->keys();
+ }
+
+ /* METHODS */
+
public function __get($key)
{
- // @todo Not sure if this is functioning correctly?
- if ($parent = parent::__get($key))
- return $parent;
+ static $details = NULL;
- // Deprecated Items
- if (! in_array($key,array_keys($this->_sampledata())))
- {
- Log::alert('No sample data for Key:',['key'=>$key]);
- return NULL;
- }
+ if ($x = parent::__get($key))
+ return $x;
- $detail = $this->getSiteDetailValue($key);
+ // Get the value from the details table
+ if (($x=$this->detail_item($key)) !== NULL)
+ return $x;
- return $detail->exists ? $detail->value : $this->getDefaultValue($key);
+ if (is_null($details))
+ $details = new SiteDetails;
+
+ // Get a default value for this key
+ $value = $details->sample($key);
+
+ // At this point our DB doesnt have this value, we'll log an alert
+ if ($this->exists)
+ Log::alert(sprintf('Site is missing value for key [%s] - providing a default [%s]',$key,serialize($value)));
+
+ return $value;
}
- private function getDefaultValue($key)
+ /* GENERAL METHODS */
+
+ /**
+ * Get a key from the site_details
+ *
+ * @param $key
+ * @return mixed
+ */
+ private function detail_item($key)
{
- $okblank = [
- 'site_address2',
- 'site_fax',
- 'social',
- 'top_menu'
- ];
+ if (($x=$this->details->search(function($item) use ($key) { return $item->key == $key; })) !== FALSE)
+ return $this->details->get($x)->value;
- if (! in_array($key,$okblank))
- Log::alert('Returning Default Value for Key:',['key'=>$key]);
-
- // Suppress some default values
- $default = [
- 'block_quotes' => '',
- 'clients' => '',
- 'page_tabs' => '',
- 'services' => '',
- 'site_description' => '',
- 'site_fax' => '',
- 'site_address2' => '',
- 'site_slider' => '',
- 'social' => [],
- 'steps' => '',
- 'testimonials' => '',
- 'top_menu' => [],
- ];
-
- return Arr::get($default,$key);
- }
-
- public function getEmailLogoAttribute()
- {
- //$return = $this->getSiteDetailValue('email_logo')->value;
- // @todo Get from the DB.
- $return = 'site/1/gthpl-white.png';
-
- return $return ? 'storage/'.$return : '/image/generic/150/20/fff';
- }
-
- public function getSiteLogoAttribute()
- {
- //$return = $this->getSiteDetailValue('site_logo')->value;
- // @todo Get from DB.
- $return = 'site/1/gth-horseradishfont-full.png';
-
- return $return ? '/storage/'.$return : '/image/generic/150/20/fff';
- }
-
- private function getSiteDetailValue($key)
- {
- $return = $this->details->where('key',$key)->first();
-
- return $return ?: (new SiteDetails);
+ return NULL;
}
/**
- * Pre-load this model with Sample Data, if there is no database record
+ * Add the path to the mail logo, so it can be displayed.
+ *
+ * @return string
*/
- private function _sampledata()
+ public function getEmailLogoAttribute()
{
- return [
- 'aboutus'=>'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 exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
- 'activity'=>[
- ['title'=>'Project 1','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/a00','image_large'=>'/image/generic/500/400/700'],
- ['title'=>'Project 2','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/b00','image_large'=>'/image/generic/500/400/800'],
- ['title'=>'Project 3','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/c00','image_large'=>'/image/generic/500/400/900'],
- ['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.',
- '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',
- 'language_id'=>1,
- '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_slider'=>[
- [
- 'title'=>'Header
and Title',
- '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.
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.
Sed est nunc, sagittis at consectetur id.',
- 'style'=>2,
- 'image'=>'url(/image/generic/500/500/eee)',
- //'button'=>['text'=>'Purchase Now','url'=>'#'],
- ],
- ],
- 'site_logo'=>route('image',['width'=>128,'height'=>32,'color'=>'eee']),
- 'site_address1'=>'Building Name',
- 'site_address2'=>NULL,
- 'site_city'=>'City',
- 'site_description'=>'Example Site',
- 'site_email'=>'nobody@example.com',
- 'site_fax'=>'+0 1 2345 6789',
- 'site_name'=>'Example',
- 'site_phone'=>'+0 1 2345 6789',
- 'site_postcode'=>'123 456',
- 'site_state'=>'State',
- 'site_tax'=>'12 123 123 123',
- 'services'=>[
- ['title'=>'Title 1','text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','icon'=>'fa fa-location-arrow blue','image'=>NULL],
- ['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'=>[
- [
- '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'=>[]],
- ['name'=>'Link 2','url'=>'#/l2', 'children'=>[]],
- ]],
- 'Option1'=>['name'=>'Option 1','url'=>'/o1','children'=>[]],
- 'Option2'=>['name'=>'Option 2','url'=>'/o2','children'=>[
- ['name'=>'O2 Link 1','url'=>'#/o2l1', 'children'=>[]],
- ['name'=>'O2 Link 1','url'=>'#/o2l2', 'children'=>[]],
- ]],
- ],
- ];
+ return (($x=$this->detail_item('email_logo')) !== NULL) ? '/storage/'.$x : '/image/generic/150/20/fff';
}
- public function sample()
+ /**
+ * Add the path to the site logo, so it can be displayed.
+ *
+ * @param $value
+ * @return string
+ */
+ public function getSiteLogoAttribute($value)
{
- return $this->forceFill($this->_sampledata());
- }
-
- public function aboutus()
- {
- // @todo To be implemented
- return Arr::get($this->_sampledata(),'aboutus');
+ return (($x=$this->detail_item('site_logo')) !== NULL) ? '/storage/'.$x : '/image/generic/150/20/fff';
}
+ // @todo - To optimize
private function _address()
{
$return = [];
@@ -300,11 +127,7 @@ class Site extends Model
return $return;
}
- public function allowed_keys(array $keys=[])
- {
- return $keys ? array_diff($keys,array_keys($this->_sampledata())) : array_keys($this->_sampledata());
- }
-
+ // @todo - To optimize
public function address($type='plain')
{
switch ($type)
diff --git a/app/Models/SiteDetails.php b/app/Models/SiteDetails.php
index 9437f96..a553979 100644
--- a/app/Models/SiteDetails.php
+++ b/app/Models/SiteDetails.php
@@ -3,20 +3,256 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
-
+use Illuminate\Support\Collection;
use Leenooks\Traits\CompositeKeys;
class SiteDetails extends Model
{
use CompositeKeys;
- public $fillable = ['site_id','key','value'];
public $incrementing = false;
protected $primaryKey = ['site_id','key'];
public $timestamps = FALSE;
+ /* RELATIONS */
+
public function site()
{
return $this->belongsTo(Site::class);
}
+
+ /* ATTRIBUTES */
+
+ public function getValueAttribute($value)
+ {
+ if (! $this->key)
+ return $value;
+
+ switch (gettype($this->_sampledata()->get($this->key))) {
+ case 'array': return unserialize($value);
+ default: return $value;
+ }
+ }
+
+ public function setKeyAttribute($value)
+ {
+ if (! $this->_sampledata()->has($value))
+ throw new \Exception(sprintf('Key [%s] is not expected.',$value));
+
+ $this->attributes['key'] = $value;
+ }
+
+ public function setValueAttribute($value)
+ {
+ // Check that the value can be set
+ if (! $this->key)
+ throw new \Exception('Please set key first');
+
+ // Check that the value is of the right type
+ $x = $this->_sampledata()->get($this->key);
+
+ if ($value && (! $this->checkType($value,$x)))
+ throw new \Exception(sprintf('Value for [%s] is not the of the correct type [%s] for this attribute, expecting [%s].',$this->key,gettype($value),gettype($this->_sampledata()->get($this->key))));
+
+ switch (gettype($x)) {
+ case 'array':
+ $this->attributes['value'] = serialize($value ?: []);
+ break;
+
+ default:
+ $this->attributes['value'] = $value ?: '';
+ }
+ }
+
+ /* GENERAL METHODS */
+
+ /**
+ * Check that two variables are the same type
+ *
+ * @param $a
+ * @param $b
+ * @return bool
+ */
+ private function checkType($a,$b): bool
+ {
+ return gettype($a) == gettype($b);
+ }
+
+ /**
+ * Pre-load this model with Sample Data, if there is no database record
+ */
+ private function _sampleData(): Collection
+ {
+ return collect([
+ /*
+ 'aboutus'=>'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 exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ 'activity'=>[
+ ['title'=>'Project 1','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/a00','image_large'=>'/image/generic/500/400/700'],
+ ['title'=>'Project 2','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/b00','image_large'=>'/image/generic/500/400/800'],
+ ['title'=>'Project 3','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/c00','image_large'=>'/image/generic/500/400/900'],
+ ['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.',
+ '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',
+ 'language_id'=>1,
+ '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_slider'=>[
+ [
+ 'title'=>'Header
and Title',
+ '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.
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.
Sed est nunc, sagittis at consectetur id.',
+ 'style'=>2,
+ 'image'=>'url(/image/generic/500/500/eee)',
+ //'button'=>['text'=>'Purchase Now','url'=>'#'],
+ ],
+ ],
+ 'services'=>[
+ ['title'=>'Title 1','text'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.','icon'=>'fa fa-location-arrow blue','image'=>NULL],
+ ['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'],
+ ],
+ */
+ 'site_address1' => 'Address line 1',
+ 'site_address2' => 'Address line 2',
+ 'site_description'=>'Example Site',
+ 'site_email' => 'nobody@example.com',
+ 'site_city' => 'City',
+ 'site_fax'=>'+0 1 2345 6789',
+ 'site_name' => 'MY OSB SITE',
+ 'site_state' => 'State',
+ 'site_phone'=>'+0 1 2345 6789',
+ 'site_postcode' => '12345',
+ 'site_tax'=>'12 123 123 123',
+ 'site_logo'=>route('image',['width'=>128,'height'=>32,'color'=>'eee']),
+ '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'=>[]],
+ ['name'=>'Link 2','url'=>'#/l2', 'children'=>[]],
+ ]],
+ 'Option1'=>['name'=>'Option 1','url'=>'/o1','children'=>[]],
+ 'Option2'=>['name'=>'Option 2','url'=>'/o2','children'=>[
+ ['name'=>'O2 Link 1','url'=>'#/o2l1', 'children'=>[]],
+ ['name'=>'O2 Link 1','url'=>'#/o2l2', 'children'=>[]],
+ ]],
+ ],
+ ]);
+ }
+
+ /**
+ * Get a sample key value
+ *
+ * @param $key
+ * @return mixed
+ * @throws \Exception
+ */
+ public function sample($key)
+ {
+ if (! $x=$this->_sampledata()->get($key))
+ throw new \Exception('Key doesnt exist: '.$key);
+
+ return $x;
+ }
}
\ No newline at end of file
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index ee8ca5b..b4ff86e 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -3,9 +3,12 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
+use Leenooks\Traits\SingleOrFail;
class AppServiceProvider extends ServiceProvider
{
+ use SingleOrFail;
+
/**
* Register any application services.
*
@@ -23,6 +26,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
- //
+ SingleOrFail::bootSingleOrfail();
}
}
diff --git a/composer.lock b/composer.lock
index 778a461..b6b34b3 100644
--- a/composer.lock
+++ b/composer.lock
@@ -2884,11 +2884,11 @@
},
{
"name": "leenooks/laravel",
- "version": "9.0.4",
+ "version": "9.0.5",
"source": {
"type": "git",
"url": "https://dev.leenooks.net/leenooks/laravel",
- "reference": "9798f6aa7dcf507e7ac7179fc348320e36aa160b"
+ "reference": "45be8553a29f1887273b10a56982f55134bfd9e0"
},
"require": {
"creativeorange/gravatar": "^1.0",
@@ -2925,7 +2925,7 @@
"laravel",
"leenooks"
],
- "time": "2021-06-29T06:38:19+00:00"
+ "time": "2021-07-01T01:58:50+00:00"
},
{
"name": "monolog/monolog",
diff --git a/database/migrations/2021_06_30_171340_rename_setup.php b/database/migrations/2021_06_30_171340_rename_setup.php
new file mode 100644
index 0000000..eef8c0f
--- /dev/null
+++ b/database/migrations/2021_06_30_171340_rename_setup.php
@@ -0,0 +1,61 @@
+dropForeign('fk_set_acc');
+ $table->dropForeign('fk_set_cty');
+ $table->dropForeign('fk_set_cur');
+ $table->dropForeign('fk_set_lan');
+ });
+
+ Schema::table('ab_setup', function (Blueprint $table) {
+ $table->dropIndex('fk_set_cty_idx');
+ $table->dropIndex('fk_set_cur_idx');
+ $table->dropIndex('fk_set_lan_idx');
+ $table->dropIndex('fk_set_acc_idx');
+ });
+ DB::statement('ALTER TABLE ab_setup RENAME TO sites');
+ DB::statement('ALTER TABLE sites MODIFY url VARCHAR(256) NOT NULL');
+ DB::statement('ALTER TABLE sites CHANGE COLUMN id site_id INT NOT NULL');
+ DB::statement('ALTER TABLE sites MODIFY admin_id INT(10) UNSIGNED NOT NULL');
+ DB::statement('ALTER TABLE sites MODIFY active TINYINT(1) NOT NULL');
+
+ Schema::table('sites', function (Blueprint $table) {
+ $table->index(['site_id']);
+ $table->dropPrimary(['site_id','country_id','currency_id','url']);
+ });
+
+ Schema::table('sites', function (Blueprint $table) {
+ $table->integer('id',TRUE)->first();
+ $table->unique(['site_id','url']);
+ $table->dropColumn(['login_expire','time_format','date_format','decimal_place','module_config','site_details']);
+
+ $table->foreign('country_id')->references('id')->on('ab_country');
+ $table->foreign('currency_id')->references('id')->on('ab_currency');
+ $table->foreign('language_id')->references('id')->on('ab_language');
+ $table->foreign(['admin_id','site_id'])->references(['id','site_id'])->on('users');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ abort(500,'cant go back');
+ }
+}
diff --git a/resources/views/theme/backend/adminlte/a/setup.blade.php b/resources/views/theme/backend/adminlte/a/setup.blade.php
index 64c4a58..1bbbd6c 100644
--- a/resources/views/theme/backend/adminlte/a/setup.blade.php
+++ b/resources/views/theme/backend/adminlte/a/setup.blade.php
@@ -3,6 +3,9 @@
@section('htmlheader_title')
Setup
@endsection
+@section('page_title')
+ Setup
+@endsection
@section('contentheader_title')
{{ $so->site_name }}
@@ -12,76 +15,190 @@
@endsection
@section('main-content')
-
- {{ trans('adminlte_lang::message.home') }} -
+Home
- Orders - -
+Orders
@@ -31,6 +25,12 @@ @can('wholesaler')Site Setup
+ +REPORT
@@ -44,4 +44,4 @@