CMS Info for Header, dyn. Tage, API

This commit is contained in:
Kevin Adametz 2019-12-28 20:15:25 +01:00
parent 7294ccc1d0
commit bed91c4f4a
49 changed files with 3476 additions and 1562 deletions

View file

@ -29,7 +29,9 @@ class CMSContentInfoController extends Controller
public function index()
{
$data = [
'days' => $this->createWeekWithDate(),
'days' => CMSInfoAvailable::getWeekWithDate(),
'specials_local' => CMSInfoAvailable::getSpecialsBy('local'),
'specials_phone' => CMSInfoAvailable::getSpecialsBy('phone'),
'cms_holidays' => CMSInfoHoliday::all(),
];
return view('cms.content.info.index', $data);
@ -52,6 +54,19 @@ class CMSContentInfoController extends Controller
}
}
//save in CMSInfoAvailable SPECIALS
if(isset($data['special_availables']) && is_array($data['special_availables'])){
foreach ($data['special_availables'] as $id=>$values){
$special_available = CMSInfoAvailable::findOrFail($id);
$cdate = \Carbon::parse($values['date']);
$values['wday'] = $cdate->dayOfWeekIso;
$special_available->fill($values)->save();
}
}
//save in CMSinfoHolidays
if(isset($data['info_holidays']) && is_array($data['info_holidays'])){
foreach ($data['info_holidays'] as $id=>$val){
@ -75,6 +90,34 @@ class CMSContentInfoController extends Controller
CMSInfoHoliday::create();
}
if($data['action'] === "add_special_available_local"){
$date = CMSInfoAvailable::getNextSpecialDateBy('local', 6);
CMSInfoAvailable::create([
'type' => 'local',
'wday' => $date->dayOfWeekIso,
'special' => true,
'active' => true,
'from' => '10:00',
'to' => '13:00',
'date' => $date->format('d.m.Y'),
]);
}
if($data['action'] === "add_special_available_phone"){
$date = CMSInfoAvailable::getNextSpecialDateBy('phone', 6);
CMSInfoAvailable::create([
'type' => 'phone',
'wday' => $date->dayOfWeekIso,
'special' => true,
'active' => true,
'from' => '10:00',
'to' => '13:00',
'date' => $date->format('d.m.Y'),
]);
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_content_infos'));
}
@ -85,6 +128,7 @@ class CMSContentInfoController extends Controller
$now = \Carbon::now();
$day_of = $now->dayOfWeekIso;
//days after now
for ($i = $day_of; $i<=7; $i++){
$days[$i] = $days[$i].' <span class="text-muted">('.$now->format("d.m.Y").')</span>';
@ -92,10 +136,12 @@ class CMSContentInfoController extends Controller
}
//days before now
for ($i = 1; $i<$day_of; $i++){
$days[$i] = $days[$i].' <span class="text-muted">('.$now->format("d.m.Y").')</span>';
for ($i = 1; $i<$day_of; $i++) {
$days[$i] = $days[$i] . ' <span class="text-muted">(' . $now->format("d.m.Y") . ')</span>';
$now->modify('+1 day');
}
//add
return $days;
}
@ -106,6 +152,12 @@ class CMSContentInfoController extends Controller
$content->delete();
\Session()->flash('alert-success', __('Content gelöscht'));
}
if($model === 'special_available'){
$content = CMSInfoAvailable::findOrFail($id);
$content->delete();
\Session()->flash('alert-success', __('Content gelöscht'));
}
return redirect(route('cms_content_infos'));
}