Media youtube, title description, CMS Info Content / Header Frontend
This commit is contained in:
parent
c9f3d85d4e
commit
7294ccc1d0
49 changed files with 1283 additions and 148 deletions
112
app/Http/Controllers/CMS/CMSContentInfoController.php
Executable file
112
app/Http/Controllers/CMS/CMSContentInfoController.php
Executable file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CMS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\CMSInfo;
|
||||
use App\Models\CMSInfoAvailable;
|
||||
use App\Models\CMSInfoHoliday;
|
||||
use App\Services\HTMLHelper;
|
||||
use Input;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
class CMSContentInfoController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'days' => $this->createWeekWithDate(),
|
||||
'cms_holidays' => CMSInfoHoliday::all(),
|
||||
];
|
||||
return view('cms.content.info.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
$data = Input::all();
|
||||
|
||||
|
||||
if($data['action'] === "saveAll"){
|
||||
|
||||
//save in CMSInfoAvailable
|
||||
if(isset($data['info_availables']) && is_array($data['info_availables'])){
|
||||
foreach ($data['info_availables'] as $type=>$values){
|
||||
foreach ($values as $wday=>$val){
|
||||
CMSInfoAvailable::setContentBySlug($type, $wday, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//save in CMSinfoHolidays
|
||||
if(isset($data['info_holidays']) && is_array($data['info_holidays'])){
|
||||
foreach ($data['info_holidays'] as $id=>$val){
|
||||
$content = CMSInfoHoliday::findOrFail($id);
|
||||
$content->fill($val);
|
||||
$content->save();
|
||||
}
|
||||
}
|
||||
|
||||
//save in CMSinfo
|
||||
if(isset($data['infos']) && is_array($data['infos'])){
|
||||
foreach ($data['infos'] as $slug=>$info){
|
||||
$type = isset($info['type']) ? $info['type'] : "text";
|
||||
$val = isset($info['val']) ? $info['val'] : "";
|
||||
CMSInfo::setContentBySlug($slug, $val, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === "add_holiday"){
|
||||
CMSInfoHoliday::create();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_content_infos'));
|
||||
}
|
||||
|
||||
|
||||
private function createWeekWithDate(){
|
||||
$days = HTMLHelper::getDeDays();
|
||||
$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>';
|
||||
$now->modify('+1 day');
|
||||
}
|
||||
|
||||
//days before now
|
||||
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');
|
||||
}
|
||||
return $days;
|
||||
}
|
||||
|
||||
public function delete($model, $id){
|
||||
|
||||
if($model === 'holiday'){
|
||||
$content = CMSInfoHoliday::findOrFail($id);
|
||||
$content->delete();
|
||||
\Session()->flash('alert-success', __('Content gelöscht'));
|
||||
}
|
||||
return redirect(route('cms_content_infos'));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue