74 lines
No EOL
2 KiB
PHP
Executable file
74 lines
No EOL
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();
|
|
}
|
|
}
|
|
//set paylines //pr_line_1
|
|
for ($i=1; $i <=8; $i++) {
|
|
if(isset($data['pr_line_'.$i])){
|
|
$data['paylines'] = $i;
|
|
}
|
|
}
|
|
if($data['id'] == "new"){
|
|
$model = UserLevel::create($data);
|
|
}else{
|
|
$model = UserLevel::find($data['id']);
|
|
$model->fill($data);
|
|
$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'));
|
|
}
|
|
*/
|
|
|
|
} |