芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/CurrencyController.php
middleware('auth:admin'); } //*** JSON Request public function datatables() { $datas = Currency::orderBy('id','desc'); return Datatables::of($datas) ->addColumn('action', function(Currency $data) { $delete = $data->is_default == 1 ? '':'
'.__("Delete").'
'; $default = $data->is_default == 1 ? '
'.__("Default").'
' : '
'.__('Set Default').'
'; return '
'.'Actions' .'
'.__("Edit").'
'.$delete.$default.'
'; }) ->rawColumns(['action']) ->toJson(); } //*** GET Request public function index() { return view('admin.currency.index'); } //*** GET Request public function create() { return view('admin.currency.create'); } //*** POST Request public function store(Request $request) { //--- Logic Section $data = new Currency(); $input = $request->all(); $isExist = Currency::where('is_default',1)->exists(); if(!$isExist){ $input['is_default'] = 1; } $data->fill($input)->save(); //--- Logic Section Ends //--- Redirect Section $msg = __('New Data Added Successfully.').' '.'
'.__('View Lists.').'
'; return response()->json($msg); //--- Redirect Section Ends } //*** GET Request public function edit($id) { $data = Currency::findOrFail($id); return view('admin.currency.edit',compact('data')); } //*** POST Request public function update(Request $request, $id) { //--- Logic Section $data = Currency::findOrFail($id); $input = $request->all(); $data->update($input); //--- Logic Section Ends //--- Redirect Section $msg = __('Data Updated Successfully.').' '.'
'.__('View Lists.').'
'; return response()->json($msg); //--- Redirect Section Ends } public function status($id1,$id2) { $data = Currency::findOrFail($id1); $data->is_default = $id2; $data->update(); $data = Currency::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) { return __("You cant't remove the main currency."); } $data = Currency::findOrFail($id); if($data->is_default == 1) { Currency::where('id','=',1)->update(['is_default' => 1]); } $data->delete(); //--- Redirect Section $msg = __('Data Deleted Successfully.'); return response()->json($msg); //--- Redirect Section Ends } }