/** * Insert new Ranking * * @param array $data * @return Ranking */ public function create_ranking(array $data) { $ranking = \DB::table('rankings')->where('ranking_date', '=', $data['ranking_date'])->where('group_id', '=', $data['group_id'])->where('location_id', '=', $data['location_id'])->where('player_id', '=', $data['player_id'])->first(); if (is_null($ranking)) { return Ranking::create(['ranking_date' => $data['ranking_date'], 'player_id' => $data['player_id'], 'ranking' => $data['ranking'], 'group_id' => $data['group_id'], 'location_id' => $data['location_id']]); } }
/** * Store a newly created Cruiseline. * * @param Request $request * @param Cruiseline $brand * @return mixed */ public function store(CreateRank $request) { $rankings = Ranking::where('rankable_type', '=', 'App\\Brochure')->delete(); $rankable_type = $request->rankable_type; $count = count($request->rankable_id); for ($i = 0; $i < $count; $i++) { $ranking = Ranking::create(['rank' => $i + 1, 'rankable_type' => $rankable_type, 'rankable_id' => $request->rankable_id[$i]]); } return redirect('home/brochurerankings'); }