23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -28,10 +28,10 @@ class CategoryController extends Controller
|
|||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id == "new"){
|
||||
if ($id == "new") {
|
||||
$model = new Category();
|
||||
$model->active = true;
|
||||
}else{
|
||||
} else {
|
||||
$model = Category::findOrFail($id);
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -46,9 +46,9 @@ class CategoryController extends Controller
|
|||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['action'] === 'save-product_category'){
|
||||
if ($data['action'] === 'save-product_category') {
|
||||
|
||||
if($data['id'] === 'new'){
|
||||
if ($data['id'] === 'new') {
|
||||
$ProductCategory = ProductCategory::create([
|
||||
'pos' => $data['pos'],
|
||||
'product_id' => $data['product_id'],
|
||||
|
|
@ -56,9 +56,9 @@ class CategoryController extends Controller
|
|||
]);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_category_edit', [$ProductCategory->category_id]));
|
||||
}else{
|
||||
} else {
|
||||
$ProductCategory = ProductCategory::findOrFail($data['id']);
|
||||
if($ProductCategory->category_id != $data['category_id']){
|
||||
if ($ProductCategory->category_id != $data['category_id']) {
|
||||
abort(404);
|
||||
}
|
||||
$ProductCategory->pos = $data['pos'];
|
||||
|
|
@ -67,63 +67,63 @@ class CategoryController extends Controller
|
|||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_category_edit', [$ProductCategory->category_id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] === 'save-form'){
|
||||
if ($data['action'] === 'save-form') {
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['parent_id'] = isset($data['parent_id']) ? $data['parent_id'] : null;
|
||||
if($data['id'] == "new"){
|
||||
if ($data['id'] == "new") {
|
||||
$model = Category::create($data);
|
||||
}else{
|
||||
} else {
|
||||
$model = Category::find($data['id']);
|
||||
$model->fill($data)->save();
|
||||
}
|
||||
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_name'])){
|
||||
|
||||
foreach ($data['trans_name'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
if (!empty($data['trans_name'])) {
|
||||
|
||||
foreach ($data['trans_name'] as $lang => $value) {
|
||||
if ($value && $value != null) {
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
|
||||
|
||||
$trans = [];
|
||||
if(!empty($data['trans_headline'])){
|
||||
foreach ($data['trans_headline'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
if (!empty($data['trans_headline'])) {
|
||||
foreach ($data['trans_headline'] as $lang => $value) {
|
||||
if ($value && $value != null) {
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->trans_headline = $trans;
|
||||
$model->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delete($do, $id){
|
||||
public function delete($do, $id)
|
||||
{
|
||||
|
||||
if($do === 'product_category'){
|
||||
if ($do === 'product_category') {
|
||||
$model = ProductCategory::findOrFail($id);
|
||||
$category = $model->category;
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
}
|
||||
if($do === 'category'){
|
||||
if(ProductCategory::where('category_id', $id)->count()){
|
||||
if ($do === 'category') {
|
||||
if (ProductCategory::where('category_id', $id)->count()) {
|
||||
\Session()->flash('alert-error', 'Eintrag hat noch Produkte, erst löschen');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
if(Category::where('parent_id', $id)->count()){
|
||||
if (Category::where('parent_id', $id)->count()) {
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Haupt-Kategorie verwendet');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
|
|
@ -132,12 +132,12 @@ class CategoryController extends Controller
|
|||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_categories'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function imageUpload(){
|
||||
public function imageUpload()
|
||||
{
|
||||
|
||||
$category_id = Request::get('category_id');
|
||||
$category = Category::findOrFail($category_id);
|
||||
|
|
@ -145,12 +145,11 @@ class CategoryController extends Controller
|
|||
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!');
|
||||
|
|
@ -166,10 +165,10 @@ class CategoryController 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
|
||||
);
|
||||
|
||||
|
|
@ -189,21 +188,20 @@ class CategoryController extends Controller
|
|||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_empty'));
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: ".$e);
|
||||
} catch (Exception $e) {
|
||||
\Session()->flash('alert-danger', "Error: " . $e);
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
}
|
||||
}
|
||||
|
||||
public function imageDelete($image_id, $category_id){
|
||||
public function imageDelete($image_id, $category_id)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($category_id);
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
|
||||
if($iq_image->id == $category->iq_image->id){
|
||||
$file = 'images/iq_images/'.$iq_image->filename;
|
||||
if ($iq_image->id == $category->iq_image->id) {
|
||||
$file = 'images/iq_images/' . $iq_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
$category->headline_image_id = NULL;
|
||||
$category->save();
|
||||
|
|
@ -212,14 +210,13 @@ class CategoryController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', __('msg.file_not_found'));
|
||||
return redirect(route('admin_product_category_edit', [$category->id]));
|
||||
|
||||
}
|
||||
|
||||
public function imageAttribute($image_id, $attr, $val = false){
|
||||
public function imageAttribute($image_id, $attr, $val = false)
|
||||
{
|
||||
|
||||
$iq_image = IqImage::findOrFail($image_id);
|
||||
|
||||
|
|
@ -228,7 +225,5 @@ class CategoryController extends Controller
|
|||
|
||||
\Session()->flash('alert-success', "Wert gespeichert");
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue