This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
site-base/app/Models/Site.php

161 lines
6.3 KiB
PHP
Raw Normal View History

2017-12-07 23:04:02 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Site extends Model
{
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');
}
}