芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/DpsPlanController.php
middleware('auth:admin'); } public function datatables() { $datas = DpsPlan::orderBy('id','desc')->get(); return Datatables::of($datas) ->editColumn('per_installment', function(DpsPlan $data) { $curr = Currency::where('is_default','=',1)->first(); return '
'.$curr->sign.$data->per_installment.'
/
'.$data->installment_interval.'
Days
for
'.$data->total_installment.'
times.
'; }) ->editColumn('final_amount', function(DpsPlan $data){ $curr = Currency::where('is_default','=',1)->first(); return '
'.$curr->sign.round($data->final_amount + $data->user_profit,2).'
'; }) ->editColumn('status', function(DpsPlan $data) { $status = $data->status == 1 ? _('activated') : _('deactivated'); $status_sign = $data->status == 1 ? 'success' : 'danger'; return '
'.$status .'
'.__("activated").'
'.__("deactivated").'
'; }) ->addColumn('action', function(DpsPlan $data) { return '
'.'Actions' .'
'.__("Edit").'
'.__("Delete").'
'; }) ->rawColumns(['per_installment','final_amount','status','action']) ->toJson(); } public function index(){ return view('admin.dpsplan.index'); } public function create(){ $data['currency'] = Currency::whereIsDefault(1)->first(); return view('admin.dpsplan.create',$data); } public function store(Request $request){ $rules = [ 'title' => 'required|max:255', 'installment_interval' => 'required', 'total_installment' => 'required', 'per_installment' => 'required', 'final_amount' => 'required', 'user_profit' => 'required', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } $input = $request->all(); $data = new DpsPlan(); $data->fill($input)->save(); $msg = 'New Plan Added Successfully.
View Plan Lists.
'; return response()->json($msg); } public function edit(Request $request, $id){ $data['data'] = DpsPlan::findOrFail($id); $data['currency'] = Currency::whereIsDefault(1)->first(); return view('admin.dpsplan.edit',$data); } public function update(Request $request, $id){ $rules = [ 'title' => 'required|max:255', 'installment_interval' => 'required', 'total_installment' => 'required', 'per_installment' => 'required', 'final_amount' => 'required', 'user_profit' => 'required', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } $data = DpsPlan::findOrFail($id); $input = $request->all(); $data->update($input); $msg = 'New Plan Updated Successfully.
View Plan Lists.
'; return response()->json($msg); } public function status($id1,$id2) { $data = DpsPlan::findOrFail($id1); $data->status = $id2; $data->update(); $msg = __('Status Updated Successfully.'); return response()->json($msg); } public function destroy($id) { $data = DpsPlan::findOrFail($id); $data->delete(); $msg = 'Plan Deleted Successfully.'; return response()->json($msg); } }