06 2022
This commit is contained in:
parent
9b0b5feb7e
commit
7a040c3e19
106 changed files with 4074 additions and 1349 deletions
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\ProductAttribute;
|
||||
use App\Models\UserLevel;
|
||||
use Request;
|
||||
|
||||
|
|
@ -19,9 +16,8 @@ class UserLevelController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => UserLevel::all(),
|
||||
'values' => UserLevel::orderBy('pos', 'asc')->get(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.level.index', $data);
|
||||
|
|
@ -31,23 +27,27 @@ class UserLevelController extends Controller
|
|||
{
|
||||
|
||||
$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([
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'margin' => $data['margin'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
$model = UserLevel::create($data);
|
||||
}else{
|
||||
$model = UserLevel::find($data['id']);
|
||||
$model->name = $data['name'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->margin = $data['margin'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
if(!empty($data['trans'])){
|
||||
/*if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
|
|
@ -58,7 +58,7 @@ class UserLevelController extends Controller
|
|||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_levels'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue