/
home
/
old_henza
/
server
/
app
/
Http
/
Controllers
/
Adm
/
File Upload :
llllll
Current File: /home/old_henza/server/app/Http/Controllers/Adm/IgnoreController.php
<?php namespace App\Http\Controllers\Adm; use App\DB\Te\TableEngine; use App\Http\Controllers\Controller; use App\Models\Major\PromotionIgnore; use Illuminate\Http\Request; class IgnoreController extends Controller { /** * Display a listing of the resource. * */ public function index() { $records = PromotionIgnore:: select([ '*', PromotionIgnore::$SELECT_CAJ, PromotionIgnore::$SELECT_TYPE_STR, ])->get(); return response()->json($records); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request */ public function store(Request $request) { $data = $request->all(); $ignore =PromotionIgnore::where('type',$data['type'])->get()->toArray(); $exist= array_column($ignore,'item_id'); foreach ($data['item_id'] as $item){ $key = array_search($item,$exist); if(!in_array($item , $exist)){ PromotionIgnore::create([ 'item_id'=>$item, 'type'=>$data['type'] ]); } else{ unset($exist[$key]); } } foreach ($exist as $value){ PromotionIgnore::where('type',$data['type'])->where('item_id',$value)->delete(); } return response()->json(true); } /** * Display the specified resource. * * @param int $id */ public function show($id) { $records = PromotionIgnore::select([ '*', PromotionIgnore::$SELECT_CAJ, PromotionIgnore::$SELECT_TYPE_STR]) ->findOrFail($id); return response()->json($records); } /** * Remove the specified resource from storage. * * @param int $type */ public function destroy($type) { PromotionIgnore::where('type',$type)->delete(); return response()->json(true); } }
Copyright ©2k19 -
Hexid
|
Tex7ure