From 324861b82631fd9f17365a44614f9fb0e536f586 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 8 Dec 2017 10:04:02 +1100 Subject: [PATCH] Started work on Site Model --- app/Http/Kernel.php | 1 + app/Http/Middleware/SetSite.php | 47 +++++ app/Models/Old/Setup.php | 20 +++ app/Models/Site.php | 162 ++++++++++++++++++ .../2017_12_05_015457_CreateTableSite.php | 66 +++++++ public/favicon.ico | Bin 0 -> 3950 bytes .../frontend/metronic/layouts/app.blade.php | 3 +- .../layouts/partials/footer.blade.php | 10 +- .../layouts/partials/htmlheader.blade.php | 6 +- .../layouts/partials/mainheader.blade.php | 4 +- routes/web.php | 7 +- terms.md | 3 - 12 files changed, 310 insertions(+), 19 deletions(-) create mode 100644 app/Http/Middleware/SetSite.php create mode 100644 app/Models/Old/Setup.php create mode 100644 app/Models/Site.php create mode 100644 database/migrations/2017_12_05_015457_CreateTableSite.php create mode 100644 public/favicon.ico delete mode 100644 terms.md diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 612552f..305c9c3 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -15,6 +15,7 @@ class Kernel extends HttpKernel */ protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, + \App\Http\Middleware\SetSite::class, ]; /** diff --git a/app/Http/Middleware/SetSite.php b/app/Http/Middleware/SetSite.php new file mode 100644 index 0000000..744432d --- /dev/null +++ b/app/Http/Middleware/SetSite.php @@ -0,0 +1,47 @@ +root()) + ->orwhere('devurl',$request->root()) + // @todo With an API call, we would use ->firstorfail(); + ->first(); + + // If we dont exist, we'll return a fake model. + if (! $so) { + $so = (new Site)->sample(); + } + + Theme::set($so->theme); + + // Set who we are in SETUP. + Config::set('SITE_SETUP',$so); + View::share('so',$so); + + return $next($request); + } +} diff --git a/app/Models/Old/Setup.php b/app/Models/Old/Setup.php new file mode 100644 index 0000000..31b3a7e --- /dev/null +++ b/app/Models/Old/Setup.php @@ -0,0 +1,20 @@ +'array', + ]; + + /** + * Pre-load this model with Sample Data, if there is no database record + */ + private function _sampledata() + { + 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.', + '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']], + 'site'=>[ + 'id'=>NULL, + 'address'=>json_decode('{"address1":"PO Box 149","address2":"7 Woodlands Court","city":"Bendigo","state":"VIC","postcode":"3550"}'), + 'address1'=>'Building Name', + 'address2'=>'123 Road Street', + 'city'=>'City', + 'description'=>'Example Site', + 'email'=>'nobody@example.com', + 'fax'=>'+0 1 2345 6789', + 'logo'=>route('image',['width'=>128,'height'=>32,'color'=>'eee']), + 'name'=>'Example', + 'postalcode'=>'123 456', + 'phone'=>'+0 1 2345 6789', + 'state'=>'State', + ], + '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'=>['facebook','linkedin','googleplus','twitter'], + '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'], + ], + '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'=>[]], + ]], + ], + ]; + } + + public function sample() + { + return $this->forceFill(array_get($this->_sampledata(),'site')); + } + + public function aboutus() + { + // @todo To be implemented + return array_get($this->_sampledata(),'aboutus'); + } + + 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->postalcode) ? ',' : ''),$this->state,$this->postalcode)); + + if (! $return) + $return = ['No Address']; + + 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) + { + case 'html' : return join('
',$this->_address()); + case 'newline': return join("\m",$this->_address()); + + default: + return join("\n",$this->_address()); + } + } + + 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'); + } +} diff --git a/database/migrations/2017_12_05_015457_CreateTableSite.php b/database/migrations/2017_12_05_015457_CreateTableSite.php new file mode 100644 index 0000000..b5752f2 --- /dev/null +++ b/database/migrations/2017_12_05_015457_CreateTableSite.php @@ -0,0 +1,66 @@ +increments('id'); + $table->timestamps(); + $table->string('url'); + $table->string("name"); + $table->string('devurl')->nullable(); + $table->text('aboutus')->nullable(); + $table->json('address')->nullable(); + $table->string('description')->nullable(); + $table->string('email'); + $table->string('phone')->nullable(); + $table->string('fax')->nullable(); + $table->string('logo')->nullable(); + $table->string('favicon')->nullable(); + $table->string('theme'); + }); + + if ($this->convert) + foreach (($this->convert)::all() as $o) + { + $so = Site::where(['url'=>rtrim($o->url,'/')])->first(); + + if (! $so) + $so = new Site; + + $so->url = rtrim($o->url,'/'); + $so->name = $o->site_details['name']; + $so->email = $o->site_details['email']; + $so->address = ['address1'=>$o->site_details['address1'],'address2'=>$o->site_details['address2'],'city'=>$o->site_details['city'],'state'=>$o->site_details['state'],'postcode'=>$o->site_details['pcode']]; + $so->phone = $o->site_details['phone']; + $so->fax = $o->site_details['fax']; + $so->theme = 'metronic-fe'; + $so->devurl = 'http://graytech'; + $so->save(); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('site'); + } +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..0ca4c86c11a30bc4f0d0eaa194fb7bb43d3b7ba7 GIT binary patch literal 3950 zcmeHKdstLu8vh+&Zs(j~xC{!390V^YB4TC6>R=!Uq%^y+hAqpwR%Uofx@c?{1`AhR zYBi$N4TXR(^FoY9fRMlhhkS9o}Mkaj}|155?T2H8q1mH}zx3k(v%I1$TZTGjRt#3rb+4JBFj)6_j$CU7JsH-~AbMq#K3qh!;sKD~2 z%W2IG(npzN+~KzmP}b}su1AyL@GOml}=Xl@aJ-lzeR1@x29 ztq-UZ6>o?k*2&Gq1#&kT0tEpInG8J3A}%%-Nl8gq@$3rd^?KZ!kPMG^YZ17$68F!4 z0%PJ+pe_3bBa4qhw=e_Q+1aRUIE3%cwBldq&x4~iPMtoD>%G0`>+i><%a`dIZb*JK z8GTgio8-HB>lPXs8!^ns2O70IYU}FIL-GD2M!-X(!Iic)bYH)Y&dNZETF%2#)R-SQ>W``W-2QA}+YmKBzx!f1px zBOm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vv&Jq0 TX}cUCEsA7ES*?~Vt7H5J)!o8` literal 0 HcmV?d00001 diff --git a/resources/theme/frontend/metronic/layouts/app.blade.php b/resources/theme/frontend/metronic/layouts/app.blade.php index 2e42aa3..0425a51 100644 --- a/resources/theme/frontend/metronic/layouts/app.blade.php +++ b/resources/theme/frontend/metronic/layouts/app.blade.php @@ -33,7 +33,6 @@ - {{-- BEGIN CORE PLUGINS (REQUIRED FOR ALL PAGES) --}} @js('/assets/jquery/1.11.2/js/jquery.min.js','jquery') @js('/assets/jquery/plugins/migrate/1.2.1/js/jquery-migrate.min.js','jq-migrate','jquery') @@ -42,7 +41,7 @@ {{-- END CORE PLUGINS --}} {{-- Scripts --}} -{!! Asset::scripts() !!} + {!! Asset::scripts() !!} @section('scripts') @include('layouts.partials.scripts') @show diff --git a/resources/theme/frontend/metronic/layouts/partials/footer.blade.php b/resources/theme/frontend/metronic/layouts/partials/footer.blade.php index 66af6ad..5348c94 100644 --- a/resources/theme/frontend/metronic/layouts/partials/footer.blade.php +++ b/resources/theme/frontend/metronic/layouts/partials/footer.blade.php @@ -24,10 +24,12 @@

Our Contacts

- - - - + + + @if($so->fax) + + @endif +
Address{!! $site_address !!}
Phone{!! $site_phone !!}
Fax{!! $site_fax !!}
Email {!! $site_email !!}
Address{!! join('
',[$so->address['address1'],$so->address['address2'],sprintf('%s, %s %s',$so->address['city'],$so->address['state'],$so->address['postcode'])]) !!}
Phone{!! $so->phone !!}
Fax{!! $so->fax !!}
Email {!! $so->email !!}
@@ -15,7 +15,7 @@ - + {{-- Fonts START --}} @@ -33,7 +33,7 @@ @css('/site/css/slider.css') @css('/site/css/style.css') @css('/site/css/style-responsive.css') - @css('/site/css/themes/red.css') + @css('/site/css/themes/blue.css') @css('/site/css/custom.css') {{-- Theme styles END --}} diff --git a/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php b/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php index 1c28635..2bca01c 100644 --- a/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php +++ b/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php @@ -5,8 +5,8 @@
    -
  • {!! $site_phone !!}
  • -
  • {!! $site_email !!}
  • +
  • {!! $so->phone !!}
  • +
  • {!! $so->email !!}
diff --git a/routes/web.php b/routes/web.php index 2e8d967..9d9531f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,11 +14,8 @@ // 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::group(['middleware'=>['setTheme:metronic-fe']], function() { - Route::get('/', 'WelcomeController@show'); - - Route::get('/home', 'HomeController@show'); -}); +Route::get('/', 'WelcomeController@show'); +Route::get('/home', 'HomeController@show'); Route::group(['middleware'=>['setTheme:adminlte-be']], function() { Route::get('/login', 'Auth\LoginController@showLoginForm'); diff --git a/terms.md b/terms.md deleted file mode 100644 index cfdbb53..0000000 --- a/terms.md +++ /dev/null @@ -1,3 +0,0 @@ -Your terms of service. - -Simply edit this file to define the terms of service for your application.