芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/RoleController.php
middleware('auth:admin'); } //*** JSON Request public function datatables() { $datas = Role::orderBy('id','desc'); //--- Integrating This Collection Into Datatables return Datatables::of($datas) ->addColumn('section', function(Role $data) { $details = str_replace('_',' ',$data->section); $details = ucwords($details); return '
'.$details.'
'; }) ->addColumn('action', function(Role $data) { return '
'.'Actions' .'
'.__("Edit").'
'.__("Delete").'
'; }) ->rawColumns(['section','action']) ->toJson(); //--- Returning Json Data To Client Side } //*** GET Request public function index() { return view('admin.role.index'); } //*** GET Request public function create() { return view('admin.role.create'); } //*** POST Request public function store(Request $request) { $data = new Role(); $input = $request->all(); if(!empty($request->section)) { $input['section'] = implode(" , ",$request->section); } else{ $input['section'] = ''; } $data->fill($input)->save(); $msg = __('New Data Added Successfully.').'
'.__('View Lists.').'
';; return response()->json($msg); } //*** GET Request public function edit($id) { $data = Role::findOrFail($id); return view('admin.role.edit',compact('data')); } //*** POST Request public function update(Request $request, $id) { //--- Validation Section $rules = [ 'photo' => '', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } //--- Validation Section Ends //--- Logic Section $data = Role::findOrFail($id); $input = $request->all(); if(!empty($request->section)) { $input['section'] = implode(" , ",$request->section); } else{ $input['section'] = ''; } $data->update($input); //--- Logic Section Ends //--- Redirect Section $msg = __('Data Updated Successfully.').'
'.__('View Lists.').'
'; return response()->json($msg); //--- Redirect Section Ends } //*** GET Request Delete public function destroy($id) { $data = Role::findOrFail($id); $data->delete(); //--- Redirect Section $msg = __('Data Deleted Successfully.'); return response()->json($msg); //--- Redirect Section Ends } }