23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\IqImage;
|
||||
use App\Models\IqSite;
|
||||
use App\Models\DashboardNews;
|
||||
use Request;
|
||||
|
||||
|
||||
|
|
@ -17,7 +18,99 @@ class SitesController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
// Dashboard News Methods
|
||||
public function dashboardNews()
|
||||
{
|
||||
$data = [
|
||||
'news' => DashboardNews::orderBy('created_at', 'DESC')->get(),
|
||||
'languages' => config('localization.supportedLocales'),
|
||||
];
|
||||
return view('admin.site.news.index', $data);
|
||||
}
|
||||
|
||||
public function dashboardNewsEdit($id)
|
||||
{
|
||||
$news = $id === 'new' ? new DashboardNews() : DashboardNews::findOrFail($id);
|
||||
$data = [
|
||||
'news' => $news,
|
||||
'languages' => config('localization.supportedLocales'),
|
||||
];
|
||||
return view('admin.site.news.edit', $data);
|
||||
}
|
||||
|
||||
public function dashboardNewsStore($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
// Handle translations
|
||||
$transTitle = [];
|
||||
$transTeaser = [];
|
||||
$transContent = [];
|
||||
|
||||
foreach (config('localization.supportedLocales') as $locale => $localeData) {
|
||||
if ($locale !== 'de') {
|
||||
$transTitle[$locale] = Request::get('trans_title_' . $locale, '');
|
||||
$transTeaser[$locale] = Request::get('trans_teaser_' . $locale, '');
|
||||
$transContent[$locale] = Request::get('trans_content_' . $locale, '');
|
||||
}
|
||||
}
|
||||
|
||||
$data['trans_title'] = $transTitle;
|
||||
$data['trans_teaser'] = $transTeaser;
|
||||
$data['trans_content'] = $transContent;
|
||||
$data['active'] = Request::has('active') ? 1 : 0;
|
||||
|
||||
// Handle file links
|
||||
$fileLinks = Request::get('file_links', []);
|
||||
// Filter out empty entries (where neither label nor file_id is set)
|
||||
$filteredFileLinks = [];
|
||||
foreach ($fileLinks as $locale => $links) {
|
||||
if (is_array($links)) {
|
||||
$filteredFileLinks[$locale] = array_values(array_filter($links, function ($link) {
|
||||
return !empty($link['file_id']) || !empty($link['label']);
|
||||
}));
|
||||
}
|
||||
}
|
||||
$data['file_links'] = $filteredFileLinks;
|
||||
|
||||
// Handle display_date
|
||||
if (!empty($data['display_date'])) {
|
||||
try {
|
||||
$data['display_date'] = \Carbon\Carbon::createFromFormat('d.m.Y', $data['display_date'])->format('Y-m-d');
|
||||
} catch (\Throwable $e) {
|
||||
$data['display_date'] = now()->format('Y-m-d');
|
||||
}
|
||||
} else {
|
||||
$data['display_date'] = now()->format('Y-m-d');
|
||||
}
|
||||
|
||||
// Wenn diese News aktiv gesetzt wird, setze alle anderen auf inaktiv
|
||||
if ($data['active']) {
|
||||
DashboardNews::where('active', 1)->update(['active' => 0]);
|
||||
}
|
||||
|
||||
if ($id === 'new') {
|
||||
DashboardNews::create($data);
|
||||
} else {
|
||||
$news = DashboardNews::findOrFail($id);
|
||||
$news->fill($data);
|
||||
$news->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-success', __('msg.saved_successfully'));
|
||||
return redirect(route('admin_dashboard_news'));
|
||||
}
|
||||
|
||||
public function dashboardNewsDelete($id)
|
||||
{
|
||||
$news = DashboardNews::findOrFail($id);
|
||||
$news->delete();
|
||||
|
||||
\Session()->flash('alert-success', __('msg.deleted_successfully'));
|
||||
return redirect(route('admin_dashboard_news'));
|
||||
}
|
||||
|
||||
public function show($site)
|
||||
|
|
@ -35,9 +128,9 @@ class SitesController extends Controller
|
|||
$data['products'] = isset($data['products']) ? $data['products'] : null;
|
||||
$data['set_products'] = isset($data['set_products']) ? $data['set_products'] : null;
|
||||
|
||||
if($site == "new"){
|
||||
// $model = IqSite::create($data);
|
||||
}else{
|
||||
if ($site == "new") {
|
||||
// $model = IqSite::create($data);
|
||||
} else {
|
||||
$model = IqSite::find(1);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
|
|
@ -45,25 +138,24 @@ class SitesController extends Controller
|
|||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_sites', ['start']));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function imageUpload($site){
|
||||
public function imageUpload($site)
|
||||
{
|
||||
|
||||
$model = IqSite::find(1);
|
||||
|
||||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
if (isset($image['output']['data'])) {
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
$file_ex = array('image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
|
|
@ -79,10 +171,10 @@ class SitesController extends Controller
|
|||
$image_name = "";
|
||||
do {
|
||||
$image_name = uniqid('', false) . '_' . $name;
|
||||
} while (\Storage::disk('public')->exists($path.$image_name));
|
||||
} while (\Storage::disk('public')->exists($path . $image_name));
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
$path.$image_name,
|
||||
$path . $image_name,
|
||||
$data
|
||||
);
|
||||
|
||||
|
|
@ -102,22 +194,21 @@ class SitesController extends Controller
|
|||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: ".$e);
|
||||
} catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: " . $e);
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
}
|
||||
}
|
||||
|
||||
public function imageDelete($site, $image_id){
|
||||
public function imageDelete($site, $image_id)
|
||||
{
|
||||
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
$model = IqSite::find(1);
|
||||
|
||||
|
||||
if($iq_image->id == $model->iq_image->id){
|
||||
$file = 'images/iq_images/'.$iq_image->filename;
|
||||
if ($iq_image->id == $model->iq_image->id) {
|
||||
$file = 'images/iq_images/' . $iq_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
$model->iq_image_id = NULL;
|
||||
$model->save();
|
||||
|
|
@ -126,14 +217,13 @@ class SitesController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('admin_sites', [$model->slug]));
|
||||
|
||||
}
|
||||
|
||||
public function imageAttribute($site, $image_id, $attr, $val = false){
|
||||
public function imageAttribute($site, $image_id, $attr, $val = false)
|
||||
{
|
||||
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
|
||||
|
|
@ -142,7 +232,5 @@ class SitesController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', "Wert gespeichert");
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue