芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/CounterController.php
middleware('auth:admin'); } //*** JSON Request public function datatables() { $datas = Counter::orderBy('id','desc')->get(); //--- Integrating This Collection Into Datatables return Datatables::of($datas) ->editColumn('count', function(Counter $data){ if($data->is_money == 1){ $count = '$ '.$data->count; }else{ $count = $data->count; } return $count; }) ->addColumn('action', function(Counter $data) { return '
'.'Actions' .'
'.__("Edit").'
'.__("Delete").'
'; }) ->rawColumns(['count', 'action']) ->toJson(); //--- Returning Json Data To Client Side } public function index() { return view('admin.counter.index'); } public function create() { return view('admin.counter.create'); } public function store(Request $request) { $rules = [ 'photo' => 'required|mimes:jpeg,bmp,png,gif', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } $data = new Counter(); $input = $request->all(); if ($file = $request->file('photo')) { $name = Str::random(8).time().'.'.$file->getClientOriginalExtension(); $file->move('assets/images',$name); $input['photo'] = $name; } if($request->is_money){ $input['is_money'] = 1; } $data->fill($input)->save(); $msg = 'New Data Added Successfully.'.'
View Counter Lists
'; return response()->json($msg); } public function edit($id) { $data = Counter::findOrFail($id); return view('admin.counter.edit',compact('data')); } public function update(Request $request, $id) { $rules = [ 'photo' => 'mimes:jpeg,bmp,png,gif', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } $data = Counter::findOrFail($id); $input = $request->all(); if ($file = $request->file('photo')) { $name = Str::random(8).time().'.'.$file->getClientOriginalExtension(); $file->move('assets/images',$name); @unlink('assets/images'.$data->photo); $input['photo'] = $name; } if($request->is_money){ $input['is_money'] = 1; }else{ $input['is_money'] = 0; } $data->update($input); $msg = 'Data Updated Successfully.'.'
View Counter Lists
'; return response()->json($msg); } public function destroy($id) { $data = Counter::findOrFail($id); $data->delete(); $msg = 'Data Deleted Successfully.'; return response()->json($msg); } }