Started work on Site Model
This commit is contained in:
parent
35473014ad
commit
324861b826
@ -15,6 +15,7 @@ class Kernel extends HttpKernel
|
|||||||
*/
|
*/
|
||||||
protected $middleware = [
|
protected $middleware = [
|
||||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||||
|
\App\Http\Middleware\SetSite::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
47
app/Http/Middleware/SetSite.php
Normal file
47
app/Http/Middleware/SetSite.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use App\Models\{Site};
|
||||||
|
use Config;
|
||||||
|
use View;
|
||||||
|
use Theme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SetSite
|
||||||
|
* This class is responsible for setting our site settings based on the URL of a request
|
||||||
|
*
|
||||||
|
* @package App\Http\Middleware
|
||||||
|
*/
|
||||||
|
class SetSite
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
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 = Site::where('url',$request->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);
|
||||||
|
}
|
||||||
|
}
|
20
app/Models/Old/Setup.php
Normal file
20
app/Models/Old/Setup.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Old;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Setup extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'ab_setup';
|
||||||
|
|
||||||
|
public function getModuleConfigAttribute($value)
|
||||||
|
{
|
||||||
|
return unserialize($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSiteDetailsAttribute($value)
|
||||||
|
{
|
||||||
|
return unserialize(gzuncompress($value));
|
||||||
|
}
|
||||||
|
}
|
162
app/Models/Site.php
Normal file
162
app/Models/Site.php
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Site extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'site';
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'address'=>'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('<br>',$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');
|
||||||
|
}
|
||||||
|
}
|
66
database/migrations/2017_12_05_015457_CreateTableSite.php
Normal file
66
database/migrations/2017_12_05_015457_CreateTableSite.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use App\Models\Site;
|
||||||
|
|
||||||
|
class CreateTableSite extends Migration
|
||||||
|
{
|
||||||
|
private $convert = 'App\Models\Old\Setup';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('site');
|
||||||
|
Schema::create('site', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
}
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
</div><!-- ./wrapper -->
|
</div><!-- ./wrapper -->
|
||||||
|
|
||||||
|
|
||||||
{{-- BEGIN CORE PLUGINS (REQUIRED FOR ALL PAGES) --}}
|
{{-- BEGIN CORE PLUGINS (REQUIRED FOR ALL PAGES) --}}
|
||||||
@js('/assets/jquery/1.11.2/js/jquery.min.js','jquery')
|
@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')
|
@js('/assets/jquery/plugins/migrate/1.2.1/js/jquery-migrate.min.js','jq-migrate','jquery')
|
||||||
@ -42,7 +41,7 @@
|
|||||||
{{-- END CORE PLUGINS --}}
|
{{-- END CORE PLUGINS --}}
|
||||||
|
|
||||||
{{-- Scripts --}}
|
{{-- Scripts --}}
|
||||||
{!! Asset::scripts() !!}
|
{!! Asset::scripts() !!}
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
@include('layouts.partials.scripts')
|
@include('layouts.partials.scripts')
|
||||||
@show
|
@show
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
<h2>Our Contacts</h2>
|
<h2>Our Contacts</h2>
|
||||||
<address class="margin-bottom-40">
|
<address class="margin-bottom-40">
|
||||||
<table>
|
<table>
|
||||||
<tr><th style="vertical-align:top; padding-right: 5px;">Address</th><td>{!! $site_address !!}</td></tr>
|
<tr><th style="vertical-align:top; padding-right: 5px;">Address</th><td>{!! join('<br>',[$so->address['address1'],$so->address['address2'],sprintf('%s, %s %s',$so->address['city'],$so->address['state'],$so->address['postcode'])]) !!}</td></tr>
|
||||||
<tr><th>Phone</th><td>{!! $site_phone !!}</tr>
|
<tr><th>Phone</th><td>{!! $so->phone !!}</tr>
|
||||||
<tr><th>Fax</th><td>{!! $site_fax !!}</tr>
|
@if($so->fax)
|
||||||
<tr><th>Email</th><td> <a href="mailto:{!! $site_email !!}">{!! $site_email !!}</a></tr>
|
<tr><th>Fax</th><td>{!! $so->fax !!}</tr>
|
||||||
|
@endif
|
||||||
|
<tr><th>Email</th><td> <a href="mailto:{!! $so->email !!}">{!! $so->email !!}</a></tr>
|
||||||
</table>
|
</table>
|
||||||
</address>
|
</address>
|
||||||
<!--
|
<!--
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{ config('app.name') }} - {{ $page_title }}</title>
|
<title>{{ config('app.name') }} - {{ $so->name }}</title>
|
||||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||||
|
|
||||||
<!-- CSRF Token -->
|
<!-- CSRF Token -->
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<meta property="og:image" content="{{ $site_logo }}" />
|
<meta property="og:image" content="{{ $site_logo }}" />
|
||||||
<meta property="og:url" content="{{ url('/') }}" />
|
<meta property="og:url" content="{{ url('/') }}" />
|
||||||
|
|
||||||
<link rel="shortcut icon" href="@yield('site_favicon','favicon.ico')" />
|
<link rel="shortcut icon" href="{{ object_get($so,'favicon','favicon.ico') }}" />
|
||||||
|
|
||||||
{{-- Fonts START --}}
|
{{-- Fonts START --}}
|
||||||
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|PT+Sans+Narrow|Source+Sans+Pro:200,300,400,600,700,900&subset=all" rel="stylesheet" type="text/css">
|
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|PT+Sans+Narrow|Source+Sans+Pro:200,300,400,600,700,900&subset=all" rel="stylesheet" type="text/css">
|
||||||
@ -33,7 +33,7 @@
|
|||||||
@css('/site/css/slider.css')
|
@css('/site/css/slider.css')
|
||||||
@css('/site/css/style.css')
|
@css('/site/css/style.css')
|
||||||
@css('/site/css/style-responsive.css')
|
@css('/site/css/style-responsive.css')
|
||||||
@css('/site/css/themes/red.css')
|
@css('/site/css/themes/blue.css')
|
||||||
@css('/site/css/custom.css')
|
@css('/site/css/custom.css')
|
||||||
{{-- Theme styles END --}}
|
{{-- Theme styles END --}}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<!-- BEGIN TOP BAR LEFT PART -->
|
<!-- BEGIN TOP BAR LEFT PART -->
|
||||||
<div class="col-md-6 col-sm-6 additional-shop-info">
|
<div class="col-md-6 col-sm-6 additional-shop-info">
|
||||||
<ul class="list-unstyled list-inline">
|
<ul class="list-unstyled list-inline">
|
||||||
<li><i class="fa fa-phone"></i><span>{!! $site_phone !!}</span></li>
|
<li><i class="fa fa-phone"></i><span>{!! $so->phone !!}</span></li>
|
||||||
<li><i class="fa fa-envelope-o"></i><span>{!! $site_email !!}</span></li>
|
<li><i class="fa fa-envelope-o"></i><span>{!! $so->email !!}</span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- END TOP BAR LEFT PART -->
|
<!-- END TOP BAR LEFT PART -->
|
||||||
|
@ -14,11 +14,8 @@
|
|||||||
// Generic Image Renderer - Render images that we dont have with a generic image
|
// 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@image')->name('image');
|
||||||
|
|
||||||
Route::group(['middleware'=>['setTheme:metronic-fe']], function() {
|
Route::get('/', 'WelcomeController@show');
|
||||||
Route::get('/', 'WelcomeController@show');
|
Route::get('/home', 'HomeController@show');
|
||||||
|
|
||||||
Route::get('/home', 'HomeController@show');
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::group(['middleware'=>['setTheme:adminlte-be']], function() {
|
Route::group(['middleware'=>['setTheme:adminlte-be']], function() {
|
||||||
Route::get('/login', 'Auth\LoginController@showLoginForm');
|
Route::get('/login', 'Auth\LoginController@showLoginForm');
|
||||||
|
Loading…
Reference in New Issue
Block a user