sidebar in cms
This commit is contained in:
parent
ed80b25b85
commit
30d5ca3b44
10 changed files with 969 additions and 378 deletions
100
app/Models/SidebarWidget.php
Normal file
100
app/Models/SidebarWidget.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SidebarWidget extends Model
|
||||
{
|
||||
|
||||
protected static $shows = [
|
||||
'home' => 'Startseite',
|
||||
'search' => 'Suche',
|
||||
'default' => 'Standartseiten',
|
||||
'overview' => 'Übersicht',
|
||||
'program' => 'Programme',
|
||||
'booking' => 'Buchungen',
|
||||
'bookingconfirm' => 'Buchungsbestätigung',
|
||||
|
||||
|
||||
];
|
||||
|
||||
protected static $components = [
|
||||
'aboutSternToursWidget' => 'Wir: STERN TOURS',
|
||||
'searchSidebarWidget' => 'Kulturreisen suchen',
|
||||
'navSidebarWidget' => 'Reiseprogramme',
|
||||
'topVotingWidget' => 'TOP bewertet',
|
||||
'feedbacksSidebarWidget' => 'Kundenfeedback',
|
||||
'travelGuideSidebarWidget' => 'Reiseführer',
|
||||
'travelMagazineSidebarWidget' => 'Reisemagazin',
|
||||
'offersSidebarWidget' => 'Angebote',
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'sidebar_widgets';
|
||||
|
||||
protected $casts = ['show_at' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'component', 'html', 'show_at', 'pos', 'active'
|
||||
];
|
||||
|
||||
|
||||
public static function getComponentsOptions($setKey = false){
|
||||
$options = self::$components;
|
||||
$ret = '<option value="">Keine Komponente laden (nur HTML)</option>\n';
|
||||
foreach ($options as $key => $option){
|
||||
$attr = ($key == $setKey) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$option.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getShowsOptions($setKey){
|
||||
if(!is_array($setKey))
|
||||
$setKey = [];
|
||||
|
||||
$options = self::$shows;
|
||||
$ret = "";
|
||||
foreach ($options as $key => $option){
|
||||
$attr = in_array($key, $setKey) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$option.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getShowsAtString(){
|
||||
$ret = "";
|
||||
if($this->show_at){
|
||||
foreach($this->show_at as $show_at){
|
||||
if(isset(self::$shows[$show_at])){
|
||||
$ret .= self::$shows[$show_at].", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtrim($ret, ", ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* public function getVotesDetailAttribute($details)
|
||||
{
|
||||
return json_decode($details, true);
|
||||
}
|
||||
then when you will call $store->votes_detail you will get the expected result.
|
||||
|
||||
After that you can use mutators to convert an array back to JSON when it is saved back in the DB. Define the method setVotesDetailAttribute($value) as follows:
|
||||
|
||||
public function setVotesDetailsAttribute($value)
|
||||
{
|
||||
$this->attributes['votes_detail'] = json_encode($value);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue