fixed dir problem

pull/49/head
A1Gard 4 months ago
parent 4848ed87de
commit f1f8c87e39

@ -22,6 +22,7 @@ class AreaController extends Controller
$valids = []; $valids = [];
foreach ($area->segment as $seg) { foreach ($area->segment as $seg) {
if (File::exists(resource_path() . '/views/segments/' . $seg)) {
$dirs = File::directories(resource_path() . '/views/segments/' . $seg); $dirs = File::directories(resource_path() . '/views/segments/' . $seg);
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
$temp = explode('/', $dir); $temp = explode('/', $dir);
@ -32,6 +33,7 @@ class AreaController extends Controller
]; ];
} }
} }
}
return view('admin.areas.area-design', compact('area', 'valids')); return view('admin.areas.area-design', compact('area', 'valids'));
} }
@ -50,12 +52,12 @@ class AreaController extends Controller
public function update(Request $request, Area $area) public function update(Request $request, Area $area)
{ {
// return $request->all(); // return $request->all();
foreach ($request->input('parts',[]) as $i => $item) { foreach ($request->input('parts', []) as $i => $item) {
$data = json_decode($item); $data = json_decode($item);
if ($data == null){ if ($data == null) {
continue; continue;
} }
if ($data->id == null){ if ($data->id == null) {
// create // create
$part = new Part(); $part = new Part();
$part->area_id = $area->id; $part->area_id = $area->id;
@ -63,7 +65,7 @@ class AreaController extends Controller
$part->part = $data->part; $part->part = $data->part;
$part->sort = $i; $part->sort = $i;
$part->save(); $part->save();
}else{ } else {
$part = Part::whereId($data->id)->first(); $part = Part::whereId($data->id)->first();
$part->segment = $data->segment; $part->segment = $data->segment;
$part->part = $data->part; $part->part = $data->part;
@ -71,29 +73,31 @@ class AreaController extends Controller
$part->save(); $part->save();
} }
} }
foreach ( json_decode($request->input('removed')) as $id){ foreach (json_decode($request->input('removed')) as $id) {
Part::where('id',$id)->first()->delete(); Part::where('id', $id)->first()->delete();
} }
\Artisan::call('client'); \Artisan::call('client');
logAdmin(__METHOD__,__CLASS__,$area->id); logAdmin(__METHOD__, __CLASS__, $area->id);
return redirect()->back()->with(['message' => __('area :NAME of website updated',['NAME' => $area->name])]); return redirect()->back()->with(['message' => __('area :NAME of website updated', ['NAME' => $area->name])]);
} }
public function sort(Area $area){ public function sort(Area $area)
return view('admin.areas.area-sort',compact('area')); {
return view('admin.areas.area-sort', compact('area'));
} }
public function sortSave(Request $request){ public function sortSave(Request $request)
foreach ($request->input('items') as $key => $v){ {
foreach ($request->input('items') as $key => $v) {
$p = Part::whereId($v['id'])->first(); $p = Part::whereId($v['id'])->first();
$p->sort = $key; $p->sort = $key;
$p->save(); $p->save();
} }
logAdmin(__METHOD__,__CLASS__,$p->area_id); logAdmin(__METHOD__, __CLASS__, $p->area_id);
return ['OK' => true,'message' => __("As you wished sort saved")]; return ['OK' => true, 'message' => __("As you wished sort saved")];
} }
} }

Loading…
Cancel
Save