public function getDomains() { return $this->hasMany(Domains::className(), ['reg_id' => 'id']); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $snip_user = \Auth::user()->id; $token = $request->ajax() ? $request->header('X-CSRF-Token') : $request->input('_token'); $remarketing = $request->input('remarketing'); $pageurls = $request->input('pageurl'); $user_id = $request->input('user_id'); $domain_id = $request->input('domain_id'); $email_service_id = $request->input('email_service_id'); $button = $request->input('create_button_snip_code'); $message = $request->input('message'); $buttontext = $request->input('buttontext'); $buttonurl = $request->input('buttonurl'); $bg_gcolor = $request->input('bg_gcolor'); $textcolor = $request->input('textcolor'); $actioncolor = $request->input('actioncolor'); $action_textcolor = $request->input('action_textcolor'); $action_type = $request->input('action_type'); $themetype = $request->input('themetype'); $posttext = $request->input('posttext'); $upload_path = $request->input('upload_path'); $feed_type = $request->input('feedtype'); $short_option = $request->input('short_option'); $short_link = $request->input('short_link'); /* * Getting Domain name for short link routing */ $domain_name = 'http://trkn.co'; $domainObj = Domains::select('name')->where('id', $domain_id)->get()->toArray(); if (is_array($domainObj) && sizeof($domainObj) > 0) { foreach ($domainObj as $key => $val) { $domain_name = $val['name']; } } if ($feed_type == 'trap.it feed') { $content = file_get_contents($pageurls); $x = new \SimpleXmlElement($content); $counter = 0; foreach ($x->entry as $entry) { $page_url = $entry->link['href'][0]; $arrrr = htmlentities($remarketing, ENT_QUOTES); $html = $this->file_get_contents_curl($page_url, array()); $title = ''; if (!empty($html)) { $doc = new \DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); $title = addslashes($nodes->item(0)->nodeValue); } $date = date('Y-m-d h:i:s'); //============Snips Creation=================// $snipObj = Snips::findOrNew($id); $snipObj->user_id = $user_id; $snipObj->domain_id = $domain_id; $snipObj->service_id = $email_service_id; $snipObj->parent_id = $snip_user; $snipObj->page_url = $page_url; $snipObj->title = $title; $snipObj->snip_type = $action_type; $snipObj->message = $message; $snipObj->snip_remarketing_code = $arrrr; $snipObj->button_text = $buttontext; $snipObj->button_url = $buttonurl; $snipObj->upload_path = $upload_path; $snipObj->date_created = $date; $snipObj->custom_short_link = $short_link; $snipObj->is_custom_short_link = $short_option; $current_id = $snipObj->update(); echo $snipObj->id; die; if ($current_id) { $snip = array("background_color" => $bg_gcolor, "text_color" => $textcolor, "action_color" => $actioncolor, "action_text_color" => $action_textcolor, "theme" => $themetype, "position" => $posttext); $layout_id = SnipLayouts::where("snip_id", $id)->update($snip); } if ($short_option == 2) { $links['data'][] = $domain_name . "/g/" . $short_link; } else { $links['data'][] = $domain_name . "/g/" . $id; } } echo json_encode($links['data']); die; } if ($feed_type == "rss feed") { $links = array(); $pageurls = $_POST['pageurl']; $content = file_get_contents($pageurls); $x = new \SimpleXMLElement($content); foreach ($x->channel->item as $entry) { $page_url = $entry->link; $arrrr = htmlentities($remarketing, ENT_QUOTES); $html = $this->file_get_contents_curl($page_url, array()); $title = ''; if (!empty($html)) { $doc = new \DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); $title = addslashes($nodes->item(0)->nodeValue); } $date = date('Y-m-d h:i:s'); //============Snips Creation=================// $snipObj = Snips::findOrNew($id); $snipObj->user_id = $user_id; $snipObj->domain_id = $domain_id; $snipObj->service_id = $email_service_id; $snipObj->parent_id = $snip_user; $snipObj->page_url = $page_url; $snipObj->title = $title; $snipObj->snip_type = $action_type; $snipObj->message = $message; $snipObj->snip_remarketing_code = $arrrr; $snipObj->button_text = $buttontext; $snipObj->button_url = $buttonurl; $snipObj->upload_path = $upload_path; $snipObj->date_created = $date; $snipObj->custom_short_link = $short_link; $snipObj->is_custom_short_link = $short_option; $current_id = $snipObj->update(); if ($current_id) { $snip = array("snip_id" => $id, "user_id" => $user_id, "background_color" => $bg_gcolor, "text_color" => $textcolor, "action_color" => $actioncolor, "action_text_color" => $action_textcolor, "theme" => $themetype, "position" => $posttext); $layout_id = SnipLayouts::where("snip_id", $id)->update($snip); } if ($short_option == 2) { $links['data'][] = $domain_name . "/g/" . $short_link; } else { $links['data'][] = $domain_name . "/g/" . $id; } } echo json_encode($links['data']); die; } else { $url = parse_url($pageurls); if (count($url) > 1) { $host = $url['scheme'] . "://"; $page_url = $host . $url['host']; if (isset($url['path'])) { $page_url .= $url['path']; } } else { $path = $url['path']; $page_url = "http://" . $path; } $arrrr = htmlentities($remarketing, ENT_QUOTES); $title = ''; $html = $this->file_get_contents_curl($page_url, array()); if (!empty($html)) { $doc = new \DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); $title = addslashes($nodes->item(0)->nodeValue); } $date = date('Y-m-d h:i:s'); //============Snips Creation=================// $snipObj = Snips::findOrNew($id); $snipObj->user_id = $user_id; $snipObj->domain_id = $domain_id; $snipObj->service_id = $email_service_id; $snipObj->parent_id = $snip_user; $snipObj->page_url = $page_url; $snipObj->title = $title; $snipObj->snip_type = $action_type; $snipObj->message = $message; $snipObj->snip_remarketing_code = $arrrr; $snipObj->button_text = $buttontext; $snipObj->button_url = $buttonurl; $snipObj->upload_path = $upload_path; $snipObj->date_created = $date; $snipObj->custom_short_link = $short_link; $snipObj->is_custom_short_link = $short_option; $current_id = $snipObj->update(); if ($current_id) { $snip = array("snip_id" => $id, "user_id" => $user_id, "background_color" => $bg_gcolor, "text_color" => $textcolor, "action_color" => $actioncolor, "action_text_color" => $action_textcolor, "theme" => $themetype, "position" => $posttext); $layout_id = SnipLayouts::where("snip_id", $snipObj->id)->update($snip); } if ($short_option == 2) { $links['data'][] = $domain_name . "/g/" . $short_link; } else { $links['data'][] = $domain_name . "/g/" . $snipObj->id; } echo json_encode($links['data']); die; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $domain = Domains::find($id); $domain->delete(); return redirect('admin/domain'); }