public function addAllWebsite() { $status = TRUE; $view = NULL; $flightId = Input::get('flightId'); $flightData = FlightBaseModel::find($flightId); // get all website $listWebsite = PublisherSiteBaseModel::where('status', 1)->lists('id'); if (!empty($listWebsite)) { foreach ($listWebsite as $websiteId) { // check flightWebsite exist $exist = FlightWebsiteBaseModel::where(array('flight_id' => $flightId, 'website_id' => $websiteId))->first(); if (empty($exist)) { $item = new FlightWebsiteBaseModel(); $item->flight_id = $flightId; $item->website_id = $websiteId; $item->type = 'adnetwork'; $item->created_by = $this->user->id; $item->updated_by = $this->user->id; $item->status = 1; $item->save(); (new Delivery())->renewCache('flight_website', $item->id); } } } $this->data['flightWebsiteList'] = $flightData->flightWebsite; $this->data['totalInventory'] = $flightData->total_inventory; $view = View::make('websiteList', $this->data)->render(); return Response::json(array('status' => $status, 'view' => $view)); }
public function removeCache($object, $objectID) { $object = strtolower($object); $renewCache = true; switch ($object) { case 'flight': $flight = $this->getFlight($objectID); if ($flight) { $flightWebsites = FlightWebsiteBaseModel::where("flight_id", $flight->id)->whereRaw("( SELECT count(*) FROM `pt_flight` WHERE `ad_format_id` = {$flight->ad_format_id} AND id = `pt_flight_website`.`flight_id` AND `status` = 1) > 0")->get(); if ($flightWebsites) { $redis = new RedisBaseModel(Config::get('redis.redis_2.host'), Config::get('redis.redis_2.port'), false); foreach ($flightWebsites as $fw) { $cacheKey = "FlightWebsite_{$fw->website_id}_{$flight->ad_format_id}"; $cachField = $fw->id; $redis->hDel($cacheKey, $cachField); } } } break; default: return false; } return true; }
/** * Store a newly created resource in storage. * @param array Form Data * @return Response */ public function updateFlight() { if (Request::ajax()) { $status = FALSE; $message = NULL; $view = NULL; $publisherBaseCost = Input::get('publisher_base_cost'); $flightWebsiteId = Input::get('flightWebsiteId'); $flightWebsite = FlightWebsiteBaseModel::where('id', $flightWebsiteId)->first(); if ($flightWebsite) { $flightWebsite->publisher_base_cost = $publisherBaseCost; if ($flightWebsite->save()) { $status = TRUE; $fpm = new FlightWebsiteBaseModel(); $this->data['listFlightWebsite'] = $fpm->getListByWebsiteId($flightWebsite->website_id); $view = View::make('flightList', $this->data)->render(); } } return Response::json(array('status' => $status, 'message' => $message, 'view' => $view)); } }
function updateTrackingSumary() { $datas = FlightWebsiteBaseModel::where("publisher_base_cost", ">", 0)->get(); foreach ($datas as $data) { DB::table('tracking_summary')->where('flight_website_id', $data->id)->update(['publisher_base_cost' => $data->publisher_base_cost]); } return ""; }