84 lines
No EOL
2.2 KiB
PHP
Executable file
84 lines
No EOL
2.2 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\UserLevel;
|
|
use Request;
|
|
|
|
|
|
class UserLevelController extends Controller
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
$this->middleware('admin');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$data = [
|
|
'values' => UserLevel::orderBy('pos', 'asc')->get(),
|
|
'trans' => array_keys(config('localization.supportedLocales')),
|
|
];
|
|
return view('admin.level.index', $data);
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
|
|
$data = Request::all();
|
|
$data['active'] = isset($data['active']) ? true : false;
|
|
$data['default'] = isset($data['default']) ? true : false;
|
|
$data['next_id'] = (isset($data['next_id']) && $data['next_id'] != 0) ? $data['next_id'] : null;
|
|
//is true -> set all other of false;
|
|
if($data['default'] === true){
|
|
$values = UserLevel::all();
|
|
foreach ($values as $value) {
|
|
$value->default = false;
|
|
$value->save();
|
|
}
|
|
}
|
|
|
|
if($data['id'] == "new"){
|
|
$model = UserLevel::create($data);
|
|
}else{
|
|
$model = UserLevel::find($data['id']);
|
|
$model->fill($data);
|
|
$model->save();
|
|
}
|
|
|
|
/*if(!empty($data['trans'])){
|
|
$trans = [];
|
|
foreach ($data['trans'] as $lang => $value){
|
|
if($value && $value != null){
|
|
$trans[$lang] = $value;
|
|
}
|
|
}
|
|
if(count($trans)){
|
|
$model->trans_name = $trans;
|
|
$model->save();
|
|
}
|
|
}*/
|
|
|
|
\Session()->flash('alert-save', '1');
|
|
return redirect(route('admin_levels'));
|
|
|
|
|
|
}
|
|
|
|
|
|
/*public function delete($id){
|
|
|
|
if(ProductAttribute::where('attribute_id', $id)->count()){
|
|
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute 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'));
|
|
}
|
|
*/
|
|
|
|
} |