本文整理汇总了PHP中Link::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Link::where方法的具体用法?PHP Link::where怎么用?PHP Link::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create \Link.
* @see Validates input using the Violin class. https://github.com/alexgarrett/violin
*/
private function create()
{
/** validate URL using Violin */
$v = new \Violin\Violin();
$v->validate(["url" => [$_POST["URL"], "required|url"]]);
if ($v->passes()) {
$url = $_POST["URL"];
/** Check if Link is already in DB */
$Link = Link::where("url", $url)->get();
if ($Link->count()) {
/** If so, just apply the old link. */
$Link = $Link[0];
$Link = $Link->getAttributes();
$short = $Link["short"];
/** Else, create a new Link */
} else {
$Link = new Link();
$Link->url = $url;
$Link->save();
$short = $Link->short;
}
/** And shit it all out. */
$this->render("New", ["short" => $this->getShortURL($short)]);
/** Validation failed. */
} else {
$this->render("Home", ["error" => "Better check your URL!"]);
}
}
示例2: postShorten
/**
* Shorten a new URL
*
* @return Response
*/
public function postShorten()
{
// No big url
if (!\Input::has('bigurl')) {
return \Response::json(array('error' => array('code' => 'MISSING-PARAMETERS', 'http_code' => '400', 'message' => 'Bad Request')), 400);
}
$bigURL = \Input::get('bigurl');
$user = $this->apiKey->user;
// No user linked to API key - SHOULD NEVER HAPPEN
if (!isset($user)) {
return \Response::json(array('error' => array('code' => 'NOT-AUTH', 'http_code' => '403', 'message' => 'Forbidden: SHOULD NEVER HAPPEN!')), 403);
}
// User has gone over quota so cant shorten
if ($user->quota_max != 0 && $user->quota_used + 1 > $user->quota_max) {
return \Response::json(array('error' => array('code' => 'QUOTA-USED', 'http_code' => '400', 'message' => 'Bad Request')), 403);
}
if (filter_var($bigURL, FILTER_VALIDATE_URL) === false) {
return \Response::json(array('error' => array('code' => 'URL-INVALID', 'http_code' => '400', 'message' => 'Bad Request')), 400);
}
$dbLink = \Link::where('destination', '=', $bigURL)->first();
if (!isset($dbLink)) {
$dbLink = new \Link();
$dbLink->user_id = $user->id;
$dbLink->code = $dbLink->generateCode();
$dbLink->destination = $bigURL;
$dbLink->clicks = "0";
$dbLink->save();
$user->quota_used += 1;
$user->save();
}
$linkCode = $dbLink->code;
$linkURL = \Request::root() . '/' . $linkCode;
return \Response::json(array('ok' => array('code' => 'LINK-SHORTENED', 'http_code' => '200', 'message' => 'OK', 'data' => array('url' => $linkURL, 'url_code' => $linkCode))), 200);
}
示例3: addNew
public function addNew()
{
//verify the user input and create account
$validator = Validator::make(Input::all(), array('Amount' => 'required|numeric'));
if ($validator->fails()) {
return Redirect::route('withdraw-get')->withErrors($validator)->withInput();
} else {
$amount = Input::get('Amount');
$todaysdate = date("Y-m-d");
$totalvisits = Link::where('username', '=', Auth::user()->username)->where('active', '=', TRUE)->sum('clicks');
$totalearned = $totalvisits * 0.1;
$withdrawn = Payment::where('user_id', '=', Auth::user()->id)->sum('amount');
$balance = $totalearned - $withdrawn;
if ($amount <= $balance) {
if ($amount >= 500) {
//register the new user
$newwithdrawal = Payment::create(array('user_id' => Auth::user()->id, 'amount' => $amount, 'withdrawal_date' => $todaysdate, 'paid' => FALSE));
if ($newwithdrawal) {
return Redirect::route('withdraw-get')->with('global', 'Success! Your Withdrawal request is being processed.');
}
} else {
return Redirect::route('withdraw-get')->with('global', 'Failed!! You are allowed to withdraw a minimum of Ksh 500.')->withInput();
}
} else {
return Redirect::route('withdraw-get')->with('global', 'Failed!! The amount exceeds your balance.')->withInput();
}
}
}
示例4: deleteAll
/**
* Delete links that have more reports then passed number.
*
* @return Response
*/
public function deleteAll()
{
if (Input::get('number') && Input::get('number') !== 0) {
$this->model->where('reports', '>=', Input::get('number'))->delete();
//fire event manually so we can flush the cache on it
Event::fire('eloquent.deleted: Link', array($this->model));
return Response::json(trans('stream::main.linkDelSuccess'), 200);
}
}
示例5: deleteLink
public function deleteLink()
{
$linkId = Input::get('memberID');
$link_delete = Link::where('id', '=', $linkId)->first();
$link_delete->active = FALSE;
$link_delete = $link_delete->save();
if ($link_delete) {
return Redirect::route('viewlink-get')->with('global', 'Success! Link information has been deleted successfully.');
}
}
示例6: getRedirect
public function getRedirect($username, $id)
{
$link = Link::where('id', '=', $id)->first();
/*Get user ip address*/
$ip_address = $_SERVER['REMOTE_ADDR'];
$device = Device::where('ip', '=', $ip_address);
if (!$device->count()) {
//record the device
$user = Device::create(array('ip' => $ip_address));
$link->clicks = $link->clicks + 1;
$link_save = $link->save();
}
return Redirect::away($link->link_name);
}
示例7: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
try {
$log = new Process();
$log->name = "get-shares";
$log->status = "running";
$log->save();
$filterDate = new DateTime('now');
$filterDate->sub(new DateInterval('P1D'));
//Load shares
Link::where('date', '>', $filterDate)->chunk(100, function ($links) {
foreach ($links as $value) {
$shares = $this->getSharesCount($value->final_url);
$ref = Stats::where('id_link', $value->id)->orderBy('created_at', 'DESC')->first();
if (!$ref) {
$ref = new stdClass();
$ref->total = 0;
}
$stat = new Stats();
$stat->id_link = $value->id;
$stat->facebook = $shares['facebook'] != null ? $shares['facebook'] : $value->facebook;
$stat->twitter = $shares['twitter'] != null ? $shares['twitter'] : $value->twitter;
$stat->linkedin = $shares['linkedin'] != null ? $shares['linkedin'] : $value->linkedin;
$stat->googleplus = $shares['googleplus'] != null ? $shares['googleplus'] : $value->googleplus;
$stat->total = $stat->facebook + $stat->twitter + $stat->linkedin + $stat->googleplus;
$stat->dif_total = $stat->total - $ref->total;
$stat->save();
$value->facebook = $stat->facebook;
$value->twitter = $stat->twitter;
$value->linkedin = $stat->linkedin;
$value->googleplus = $stat->googleplus;
$value->total = $stat->total;
$value->save();
}
});
$log->status = "finished";
$log->save();
} catch (Exception $e) {
$this->info($url);
$this->info($e->getMessage());
}
}
示例8: loadRss
private function loadRss($rss)
{
try {
$feed = FeedReader::read($rss->url);
$data = array();
foreach ($feed->get_items() as $key => $value) {
//Fallback bad url
$url = $value->get_id();
$url = filter_var($url, FILTER_VALIDATE_URL) === FALSE ? $value->get_permalink() : $url;
$link = Link::where('url', $url)->get()->first();
if (is_null($link)) {
$htmlParts = $this->getFinalURL($url);
$final_url = $htmlParts['final_url'];
$this->info($final_url);
if (strpos($final_url, "/") == 0) {
$orig = parse_url($url);
$final_url = $orig['scheme'] . '://' . $orig['host'] . $final_url;
$this->info($final_url);
}
//'Y-m-d H:i:s'
$date = strtotime($value->get_date());
//Fallback bad dates
if (strpos($date, '1969') == 0) {
$date = new DateTime();
} else {
$date = date('Y-m-d H:i:s', $date);
}
$image = $this->getImage($value, $htmlParts['og_image']);
$data[] = array('url' => $url, 'final_url' => $final_url, 'title' => html_entity_decode($value->get_title()), 'image' => $image, 'id_rss' => $rss->id, 'id_tag' => $rss->id_tag, 'id_newspaper' => $rss->id_newspaper, 'date' => $date, 'facebook' => 0, 'twitter' => 0, 'linkedin' => 0, 'googleplus' => 0, 'updated_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'));
} else {
$link->touch();
}
}
} catch (Exception $e) {
$this->info($rss->url);
$this->info($e->getTraceAsString());
}
if (count($data)) {
Link::insert($data);
}
}
示例9: show
public function show($series, $seasonNum, $episodeNum)
{
$title = Title::byId($series);
foreach ($title->season as $value) {
if ($value->number == $seasonNum) {
$season = $value;
}
}
if (isset($season)) {
foreach ($season->episode as $value) {
if ($value->episode_number == $episodeNum) {
$episode = $value;
}
}
}
if (!isset($episode)) {
App::abort(404);
}
$links = Link::where('title_id', $title->id)->where('season', $season->number)->where('episode', $episode->episode_number)->get();
return View::make('Titles.Episodes.Show')->with('title', $title)->with('episode', $episode)->with('season', $season)->with('links', $links);
}
示例10: getIndex
public function getIndex($slug = '', $link_id = 0)
{
$debug = '';
$bmStart = microtime(true);
$perpage = intval(AppConfig::get('articles_per_page', 50));
$branch_prefixes = explode(',', AppConfig::get('branch_prefixes'));
$virtualPerpage = intval(AppConfig::get('virtual_per_page', 20));
$page = Page::where('slug', '=', $slug)->cacheTags('pages')->remember(1440)->first();
//$page = Page::where('slug', '=', Str::slug($slug))->first();
if (count($page) > 0) {
if ($filter_return = $this->authFilter($page->level)) {
return $filter_return;
}
if ($page->redirect) {
if (substr($page->redirect, 0, 1) == '{') {
$redir_arr = json_decode($page->redirect, true);
foreach ($redir_arr as $rlvl => $rslug) {
if (strpos($this->auth_lvl, $rlvl) !== false) {
return Redirect::to($rslug);
}
}
if (isset($redir_arr['def'])) {
return Redirect::to($redir_arr['def']);
}
} else {
return Redirect::to($page->redirect);
}
}
// get parameters from URL
$page->category = Input::has('category') ? Input::get('category') : ($page->default_category ? $page->default_category : false);
$page->section = Input::has('section') ? Input::get('section') : false;
$page->keywordInput = $page->ddkeycol ? Input::get('keyword') : '';
$page_vars = new stdClass();
// separate slug into branch and section, if applicable
$branch = $slug;
if ($page->link_slug) {
$branch = $page->link_slug;
}
$els = explode('/', $branch);
if (in_array($els[0], $branch_prefixes) && count($els) > 1) {
$branch = $els[0];
if (!$page->section) {
$page->section = $els[1];
}
}
$dta = normal::getTypes();
// get list of categories, if there is a "ddlist"
$categories = false;
$normalized = false;
if ($page->ddlist) {
$fld = $page->ddlist;
$catq = Link::where('branch', '=', $branch);
if ($page->section) {
$catq->where('section', '=', $page->section);
}
if ($dtp = array_search($fld, $dta)) {
$catq->join('data', 'data.rec_id', '=', 'links.id')->where('data.table_name', '=', 'links')->where('data.type', '=', $dtp)->whereNull('data.deleted_at');
$fld = 'data_body';
$normalized = true;
}
$category_model = $catq->groupBy($fld)->whereRaw('trim(`' . $fld . '`) != ""')->cacheTags('links')->remember(1440)->get(array($fld));
$categories = array('' => 'All');
foreach ($category_model as $category_item) {
$categories[$category_item->{$fld}] = $category_item->{$fld};
}
}
$links = false;
$columns = false;
// get list of links, specified by branch, section, category, state, and/or keyword
if ($page->linkdef || $link_id && $page->detaildef) {
// get column layout
$columns = Listcolumns::where('def', '=', $link_id ? $page->detaildef : $page->linkdef)->cacheTags('links')->remember(1440)->orderBy('listorder')->get();
$perlinkpage = intval(AppConfig::get('links_per_page', 50));
$query = new Link();
if ($link_id) {
$query = $query->where('id', '=', $link_id);
} else {
if ($page->section) {
$query = $query->where('section', '=', $page->section);
}
if ($page->category) {
if ($normalized) {
$query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', $dtp)->whereNull('d.deleted_at');
}
$query = $query->where(isset($fld) ? $fld : ($page->section ? 'category' : 'section'), '=', $page->category);
}
if ($page->state) {
$query = $query->where('state', '=', $page->state);
}
if ($page->keywordInput) {
if ($page->keywordInput == "by_date") {
$query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', 7)->whereNull('d.deleted_at');
$month = Input::get('themonth');
$year = Input::get('theyear');
$pfx = $year . '-' . $month;
$start_date = $pfx . '-01';
$end_date = $pfx . '-' . cal_days_in_month(CAL_GREGORIAN, $month, $year);
$query = $query->whereRaw('d.`data_body` BETWEEN ? AND ?', array($start_date, $end_date));
unset($page->keywordInput);
$page_vars->month = $month;
//.........这里部分代码省略.........
示例11: del_link
public function del_link($slug)
{
$link = Link::where(['id' => $slug])->firstOrFail();
$link->delete();
View::success('彻底删除成功', 'http://' . __HOST__ . '/admin/link/');
die;
}
示例12: getSiteIndexs
public function getSiteIndexs($char)
{
$check = false;
$disablechar = [];
$thaichar = array('ก', 'ข', 'ค', 'ง', 'จ', 'ฉ', 'ช', 'ซ', 'ฌ', 'ญ', 'ฐ', 'ฑ', 'ฒ', 'ณ', 'ด', 'ต', 'ถ', 'ท', 'ธ', 'น', 'บ', 'ป', 'ผ', 'ฝ', 'พ', 'ฟ', 'ภ', 'ม', 'ย', 'ร', 'ล', 'ว', 'ศ', 'ษ', 'ส', 'ห', 'ฬ', 'อ', 'ฮ');
$thaivowel = array('เ', 'แ', 'ใ', 'ไ', 'โ');
if (!isset($char)) {
$char = "ก";
}
for ($i = 0; $i < count($thaichar); $i++) {
if ($char == $thaichar[$i]) {
$check = true;
}
}
if (!$check) {
App::abort(404);
}
$links = Link::where('name', 'LIKE', $char . '%')->get();
for ($i = 0; $i < count($thaivowel); $i++) {
$links = $links->merge(Link::where('name', 'LIKE', $thaivowel[$i] . $char . '%')->get());
}
for ($i = 0; $i < count($thaichar); $i++) {
$checkChar = Link::where('name', 'LIKE', $thaichar[$i] . '%')->get();
for ($j = 0; $j < count($thaivowel); $j++) {
$checkChar = $checkChar->merge(Link::where('name', 'LIKE', $thaivowel[$j] . $thaichar[$i] . '%')->get());
}
if (count($checkChar) == 0) {
$disablechar[] = $thaichar[$i];
}
}
$this->breadcrumbs->push('Site Index', URL::to('/site-index'));
$this->breadcrumbs->generate();
return View::make('home.site-index')->with('thaiChar', $thaichar)->with('char', $char)->with('links', $links)->with('disablechar', $disablechar);
}
示例13: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$dbLink = \Link::where('code', '=', $id)->first();
if (!isset($dbLink)) {
Response::make("Link not found, please try again!", 404);
}
$dbLink->clicks = bcadd($dbLink->clicks, "1");
$dbLink->save();
return \Redirect::away($dbLink->destination);
}
示例14: run
public function run()
{
$link = Link::where('url', '=', 'Link')->take(1)->get();
var_dump($link);
exit();
}
示例15: artice
/**
* [artice 文章内容]
* @return [type] [description]
*/
public function artice($slug)
{
$webSite = Website::find(1)->toArray();
$arcData = Article::with('belongsToCategory')->find($slug)->toArray();
//print_r($arcData);
$hotArcData = Article::with('belongsToCategory')->where(['is_del' => 0])->get()->toArray();
$linkData = Link::where(['is_look' => 1])->get()->toArray();
//print_r($linkData);
$cateData = Category::where(['is_del' => 0])->get()->toArray();
//print_r($cateData);
$item = [];
foreach ($cateData as $k => $v) {
if (!isset($item[$v['id']])) {
$item[$v['id']] = $v;
} else {
$item[$v['id']] = $v;
}
}
//上一篇
$pre = Article::get_pre($slug);
//print_r($pre);
//下一篇
$next = Article::get_next($slug);
//print_r($next);
//相关文章
$this->smarty->assign('pre', $pre);
$this->smarty->assign('next', $next);
$this->smarty->assign('webSite', $webSite);
$this->smarty->assign('hotArcData', $hotArcData);
$this->smarty->assign('cateData', $item);
$this->smarty->assign('slug', $slug);
$this->smarty->assign('linkData', $linkData);
$this->smarty->assign('article', $arcData);
$this->smarty->display('Index/article.html');
}