April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\Ingredient;
|
||||
use App\Models\PackagingItem;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductImage;
|
||||
use App\Models\ProductIngredient;
|
||||
|
|
@ -10,8 +12,6 @@ use App\Repositories\ProductRepository;
|
|||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
protected $productRepo;
|
||||
|
|
@ -24,35 +24,40 @@ class ProductController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
if(Request::get('show_active_products')){
|
||||
if (Request::get('show_active_products')) {
|
||||
set_user_attr('show_active_products', Request::get('show_active_products'));
|
||||
}
|
||||
if(get_user_attr('show_active_products') === "true"){
|
||||
if (get_user_attr('show_active_products') === 'true') {
|
||||
$values = Product::where('active', true)->orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get();
|
||||
}else{
|
||||
} else {
|
||||
$values = Product::orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get();
|
||||
|
||||
}
|
||||
$data = [
|
||||
'values' => $values
|
||||
'values' => $values,
|
||||
];
|
||||
|
||||
return view('admin.product.index', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
$model = new Product();
|
||||
if ($id === 'new') {
|
||||
$model = new Product;
|
||||
$model->active = true;
|
||||
}else{
|
||||
} else {
|
||||
$model = Product::findOrFail($id);
|
||||
$model->load(['packagings.packagingMaterial']);
|
||||
}
|
||||
|
||||
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
|
||||
$data = [
|
||||
'product' => $model,
|
||||
'country_for_prices' => $country_for_prices,
|
||||
'ingredient_catalog' => Ingredient::query()->where('active', true)->with('materialQuality')->orderBy('name')->get(['id', 'name', 'inci', 'effect', 'default_factor', 'material_quality_id']),
|
||||
'packaging_catalog' => PackagingItem::query()->where('active', true)->with('packagingMaterial')->orderBy('name')->get(),
|
||||
];
|
||||
|
||||
return view('admin.product.edit', $data);
|
||||
}
|
||||
|
||||
|
|
@ -61,34 +66,36 @@ class ProductController extends Controller
|
|||
|
||||
$data = Request::all();
|
||||
|
||||
$rules = array(
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
);
|
||||
];
|
||||
/*if(isset($data['number']) && $data['number'] != ""){
|
||||
$rules['number'] = 'int';
|
||||
}*/
|
||||
if(isset($data['wp_number'])){
|
||||
if($data['id'] !== "new"){
|
||||
if (isset($data['wp_number'])) {
|
||||
if ($data['id'] !== 'new') {
|
||||
$model = Product::findOrFail($data['id']);
|
||||
$rules['wp_number'] = 'unique:products,wp_number,'.$model->id;
|
||||
}else{
|
||||
} else {
|
||||
$rules['wp_number'] = 'unique:products,wp_number';
|
||||
|
||||
}
|
||||
}
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if($data['id'] === "new"){
|
||||
$model = new Product();
|
||||
}else{
|
||||
if ($data['id'] === 'new') {
|
||||
$model = new Product;
|
||||
} else {
|
||||
$model = Product::findOrFail($data['id']);
|
||||
$model->load(['packagings.packagingMaterial']);
|
||||
}
|
||||
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
|
||||
|
||||
$data = [
|
||||
'product' => $model,
|
||||
'country_for_prices' => $country_for_prices,
|
||||
|
||||
'ingredient_catalog' => Ingredient::query()->where('active', true)->with('materialQuality')->orderBy('name')->get(['id', 'name', 'inci', 'effect', 'default_factor', 'material_quality_id']),
|
||||
'packaging_catalog' => PackagingItem::query()->where('active', true)->with('packagingMaterial')->orderBy('name')->get(),
|
||||
];
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
|
@ -98,34 +105,41 @@ class ProductController extends Controller
|
|||
} else {
|
||||
$product = $this->productRepo->update(Request::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
public function copy($id){
|
||||
public function copy($id)
|
||||
{
|
||||
$model = Product::findOrFail($id);
|
||||
$product = $this->productRepo->copy($model);
|
||||
\Session()->flash('alert-success', 'Eintrag kopiert');
|
||||
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
public function delete($id, $do = 'product', $did = null){
|
||||
if($do === 'product'){
|
||||
public function delete($id, $do = 'product', $did = null)
|
||||
{
|
||||
if ($do === 'product') {
|
||||
$model = Product::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
|
||||
return redirect(route('admin_product_show'));
|
||||
}
|
||||
|
||||
if($do === 'ingredient'){
|
||||
if ($do === 'ingredient') {
|
||||
$model = Product::findOrFail($id);
|
||||
$ProductIngredient = ProductIngredient::where('ingredient_id', $did)->where('product_id', $model->id)->first();
|
||||
if($ProductIngredient){
|
||||
if ($ProductIngredient) {
|
||||
$ProductIngredient->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
|
||||
return redirect(route('admin_product_edit', [$model->id]));
|
||||
}
|
||||
|
||||
|
|
@ -134,24 +148,29 @@ class ProductController extends Controller
|
|||
}
|
||||
|
||||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
public function imageUpload(){
|
||||
public function imageUpload()
|
||||
{
|
||||
|
||||
if(Request::has('product_id')){
|
||||
if (Request::has('product_id')) {
|
||||
$product = Product::findOrFail(Request::get('product_id'));
|
||||
|
||||
return \App\Services\ProductImage::imageUpload('product', $product, Request::get('upload_type'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function imageDelete($product_image_id, $product_id){
|
||||
public function imageDelete($product_image_id, $product_id)
|
||||
{
|
||||
$product = Product::findOrFail($product_id);
|
||||
|
||||
return \App\Services\ProductImage::imageDelete('product', $product, $product_image_id);
|
||||
|
||||
}
|
||||
|
||||
public function imageAttribute($product_id, $attr, $val = false){
|
||||
public function imageAttribute($product_id, $attr, $val = false)
|
||||
{
|
||||
|
||||
if(is_numeric($val) && $val < 0){
|
||||
if (is_numeric($val) && $val < 0) {
|
||||
$val = 0;
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +179,9 @@ class ProductController extends Controller
|
|||
$product_image->{$attr} = $val;
|
||||
$product_image->save();
|
||||
|
||||
\Session()->flash('alert-success', "Wert gespeichert");
|
||||
\Session()->flash('alert-success', 'Wert gespeichert');
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue