<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Admin;use App\Models\CashRateLog;use App\Models\CashRateSetting;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use Illuminate\Support\Facades\Auth;class CashRateController extends Controller{public function index(){$rate=CashRateSetting::get();return view('admin.account.rate.index',compact('rate'));}public function edit($id){$info=CashRateSetting::find($id);return view('admin.account.rate.edit',compact('info','id'));}public function data(){$res=CashRateSetting::with(['user'=>function($query){$query->select('id','username');}])->paginate(10)->toArray();$P2gAC0=array();$P2gAC0['code']=0;$P2gAC0['msg']='正在请求中...';$P2gAC0['count']=$res['total'];$P2gAC0['data']=$res['data'];$data=$P2gAC0;return response()->json($data);}public function store(Request $request){$uid=auth()->user()->id;$info=CashRateSetting::find($request->id);$data=$request->except(['_token','id']);$data['status']=1;CashRateSetting::where(['id'=>$request->id])->update($data);CashRateLog::create(['uid'=>$uid,'before_rate'=>$info->rate,'after_rate'=>$data['rate'],'type'=>$info->type]);return redirect()->route('admin.cash.rate');}}
?>