芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/PageController.php
middleware('auth:admin'); } public function datatables() { $datas = Page::orderBy('id','desc'); return Datatables::of($datas) ->editColumn('status', function(Page $data) { $status = $data->status == 1 ? __('Activated') : __('Deativated'); $status_sign = $data->status == 1 ? 'success' : 'danger'; return '
'.$status .'
'.__("Active").'
'.__("Deativate").'
'; }) ->addColumn('action', function(Page $data) { return '
'.'Actions' .'
'.__("Edit").'
'.__("Delete").'
'; }) ->rawColumns(['status','action']) ->toJson(); //--- Returning Json Data To Client Side } public function index() { return view('admin.page.index'); } public function create() { return view('admin.page.create'); } public function store(Request $request) { $slug = $request->slug; $main = array('home','faq','contact','blog','cart','checkout'); if (in_array($slug, $main)) { return response()->json(array('errors' => [ 0 => 'This slug has already been taken.' ])); } $rules = ['slug' => 'unique:pages']; $customs = ['slug.unique' => 'This slug has already been taken.']; $validator = Validator::make($request->all(), $rules, $customs); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } $data = new Page(); $input = $request->all(); $common_rep = ["value", "{", "}", "[","]",":","\""]; $metatag = str_replace($common_rep, '', $request->meta_tag); if ($metatag) { $input['meta_tag'] = $metatag; } if ($request->secheck == "") { $input['meta_tag'] = null; $input['meta_description'] = null; } $input['details'] = Purifier::clean($request->details); $data->fill($input)->save(); $msg = 'New Data Added Successfully.'.'
View Page Lists
'; return response()->json($msg); } public function edit($id) { $data = Page::findOrFail($id); return view('admin.page.edit',compact('data')); } public function update(Request $request, $id) { $data = Page::findOrFail($id); $input = $request->all(); $common_rep = ["value", "{", "}", "[","]",":","\""]; $metatag = str_replace($common_rep, '', $request->meta_tag); if ($metatag) { $input['meta_tag'] = $metatag; } else { $input['meta_tag'] = null; } if ($request->secheck == "") { $input['meta_tag'] = null; $input['meta_description'] = null; } $input['details'] = Purifier::clean($request->details); $data->update($input); $msg = 'Data Updated Successfully.'.'
View Page Lists
'; return response()->json($msg); } public function status($id1,$id2) { $data = Page::findOrFail($id1); $data->status = $id2; $data->update(); $mgs = __('Data Update Successfully.'); return response()->json($mgs); } public function destroy($id) { $data = Page::findOrFail($id); $data->delete(); //--- Redirect Section $msg = 'Data Deleted Successfully.'; return response()->json($msg); //--- Redirect Section Ends } }