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

namespace App\Http\Controllers\Admin;use App\Http\Requests\ProductColumnCreateRequest;use App\Http\Requests\ProductColumnUpdateRequest;use App\Models\ProductColumn;use Illuminate\Http\Request;use App\Http\Controllers\Controller;class ProductColumnController extends Controller{public function index(){return view('admin.product_column.index');}public function data(Request $request){$pageSize=$request->input('limit',$this->pageSize);$name=$request->input('name','');$field=$request->input('field','sort');$order=$request->input('order','desc');$res=ProductColumn::select();if($name)goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$res->where('name','like',"%".$name."%");goto P2gx1;P2gNextx2:P2gx1:$res=$res->orderBy($field,$order)->paginate($pageSize)->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(){$P2g0=new ProductColumn();$productColumn=$P2g0;return view('admin.product_column.create',compact('productColumn'));}public function store(ProductColumnCreateRequest $request){$data=$request->except(['_method','_token']);if(ProductColumn::create($data))goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:return response()->json(['code'=>0,'msg'=>'保存成功']);goto P2gx3;P2gNextx4:return response()->json(['code'=>1,'msg'=>'保存失败']);P2gx3:}public function show($id){}public function edit($id){$productColumn=ProductColumn::findOrFail($id);return view('admin.product_column.edit',compact('productColumn'));}public function update(ProductColumnUpdateRequest $request,$id){$productColumn=ProductColumn::findOrFail($id);$data=$request->except(['_method','_token','id']);if($productColumn->update($data))goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:return response()->json(['code'=>0,'msg'=>'修改成功']);goto P2gx5;P2gNextx6:return response()->json(['code'=>1,'msg'=>'修改失败']);P2gx5:}public function destroy(Request $request){$ids=$request->get('ids');$P2g0=!$ids;if($P2g0)goto P2gBodyx8;goto P2gNextx8;P2gBodyx8:return response()->json(['code'=>1,'msg'=>'请选择删除项']);goto P2gx7;P2gNextx8:P2gx7:if(ProductColumn::whereIn('id',$ids)->delete())goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:return response()->json(['code'=>0,'msg'=>'删除成功']);goto P2gx9;P2gNextxa:return response()->json(['code'=>1,'msg'=>'删除失败']);P2gx9:}}
?>