芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/FontController.php
middleware('auth:admin'); } //*** JSON Request public function datatables() { $datas = Font::orderBy('id','desc'); //--- Integrating This Collection Into Datatables return Datatables::of($datas) ->addColumn('action', function(Font $data) { $delete = $data->is_default == 1 ? '':'
'.__("Delete").'
'; $default = $data->is_default == 1 ? '
'.__("Default").'
' : '
'.__('Set Default').'
'; return '
'.'Actions' .'
'.__("Edit").'
'.$delete.$default.'
'; }) ->rawColumns(['action']) ->toJson(); //--- Returning Json Data To Client Side } //*** GET Request public function index() { return view('admin.font.index'); } //*** GET Request public function create() { return view('admin.font.create'); } public function store(Request $request){ //--- Validation Section $rules = [ 'font_family' => 'required|unique:fonts', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } //--- Validation Section Ends $data = new Font(); $input = $request->all(); $input['font_value'] = preg_replace('/\s+/', '+',$request->font_family); if (Font::where('is_default', 1)->count() > 0) { $input['is_default'] = 0; } else { $input['is_default'] = 1; } $data->fill($input)->save(); //--- Redirect Section $msg = 'New Data Added Successfully.'.'
View Post Lists
'; return response()->json($msg); //--- Redirect Section Ends } public function edit($id){ $data['data'] = Font::findOrFail($id); return view('admin.font.edit',$data); } public function update(Request $request,$id){ //--- Validation Section $rules = [ 'font_family' => 'required|unique:fonts,font_family,'.$id, ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } //--- Validation Section Ends $data = Font::find($id); $input = $request->all(); $input['font_value'] = preg_replace('/\s+/', '+',$request->font_family); $data->update($input); //--- Redirect Section $msg = 'Data Updated Successfully.'.' '.'
'.__('View Lists.').'
'; return response()->json($msg); //--- Redirect Section Ends } public function status($id1,$id2) { $data = Font::findOrFail($id1); $data->is_default = $id2; $data->update(); $data = Font::where('id','!=',$id1)->update(['is_default' => 0]); //--- Redirect Section $msg = __('Data Updated Successfully.'); return response()->json($msg); //--- Redirect Section Ends } //*** GET Request Delete public function destroy($id) { if($id == 1) { $msg = __("You don't have access to remove this font."); return response()->json($msg); } $data = Font::findOrFail($id); if($data->is_default == 1) { $msg = __("You can not remove default font."); return response()->json($msg); } $data->delete(); //--- Redirect Section $msg = __('Data Deleted Successfully.'); return response()->json($msg); //--- Redirect Section Ends } }