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

namespace App\Http\Controllers\Admin;use App\Http\Requests\CircleRequest;use App\Models\Circle;use App\Models\Help;use Illuminate\Http\Request;use App\Http\Controllers\Controller;class CircleController extends Controller{public function index(){return view('admin.website.circle.index');}public function data(Request $request){$model=Circle::query();$res=$model->orderBy('created_at','desc')->paginate($request->get('limit',30))->toArray();$P2gAC0=array();$P2gAC0['code']=0;$P2gAC0['msg']='正在请求中...';$P2gAC0['count']=$res['total'];$P2gAC0['data']=$res['data'];$data=$P2gAC0;return response()->json($data);}public function create(){$slug=Circle::pluck('slug')->toArray();return view('admin.website.circle.create',compact('slug'));}public function store(CircleRequest $request){$data=$request->all();Circle::create($data);return redirect()->route('admin.website.circle')->with('status','圈子添加成功！');}public function show($id){}public function edit($id){$circle=Circle::find($id);$slug=Circle::pluck('slug')->toArray();return view('admin.website.circle.edit',compact('circle','slug'));}public function update(Request $request,$id){$circle=Circle::findOrFail($id);$data=$request->all();if($circle->update($data))goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:return redirect(route('admin.website.circle'))->with(['status'=>'更新成功']);goto P2gx1;P2gNextx2:P2gx1:return redirect(route('admin.website.circle'))->withErrors(['status'=>'系统错误']);}public function destroy(Request $request){$ids=$request->get('ids');if(empty($ids))goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:return response()->json(['code'=>1,'msg'=>'请选择删除项']);goto P2gx3;P2gNextx4:P2gx3:foreach(Circle::whereIn('id',$ids)->get()as $model){$model->delete();}return response()->json(['code'=>0,'msg'=>'删除成功']);}}
?>