Updates to 03-2025
This commit is contained in:
parent
6167273a48
commit
9b54eb0512
348 changed files with 34535 additions and 5774 deletions
|
|
@ -3,9 +3,10 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\ProductAttribute;
|
||||
use Request;
|
||||
use App\Models\Attribute;
|
||||
use App\Models\AttributeType;
|
||||
use App\Models\ProductAttribute;
|
||||
|
||||
|
||||
class AttributeController extends Controller
|
||||
|
|
@ -20,33 +21,64 @@ class AttributeController extends Controller
|
|||
{
|
||||
|
||||
$data = [
|
||||
'values' => Attribute::all(),
|
||||
'attribute_types' => AttributeType::all(),
|
||||
'attributes' => Attribute::all(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.attribute.index', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = Attribute::create([
|
||||
'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = Attribute::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
if(isset($data['action'])){
|
||||
|
||||
if(!empty($data['trans'])){
|
||||
if( $data['action'] === "attribute-type"){
|
||||
if($data['id'] == "new"){
|
||||
$model = AttributeType::create([
|
||||
'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'description' => $data['description'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = AttributeType::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->description = $data['description'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
if($data['action'] === "attribute"){
|
||||
if($data['id'] == "new"){
|
||||
$model = Attribute::create([
|
||||
'parent_id' => null,
|
||||
'attribute_type_id' => $data['attribute_type_id'],
|
||||
'name' => $data['name'],
|
||||
'value' => $data['value'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = Attribute::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->value = $data['value'];
|
||||
$model->attribute_type_id = $data['attribute_type_id'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
|
|
@ -57,7 +89,7 @@ class AttributeController extends Controller
|
|||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
|
|
@ -66,21 +98,41 @@ class AttributeController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
public function delete($attr, $id){
|
||||
|
||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
|
||||
if($attr === 'type'){
|
||||
if(Attribute::where('attribute_type_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Attribute Type wird bei den Attributen verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(AttributeType::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
$model = AttributeType::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Attribute Type gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(Attribute::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_industry_sectors'));
|
||||
|
||||
if($attr === 'attr'){
|
||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Attribute wird bei den Produkten verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(Attribute::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue