本文整理汇总了PHP中app\models\News::where方法的典型用法代码示例。如果您正苦于以下问题:PHP News::where方法的具体用法?PHP News::where怎么用?PHP News::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\News
的用法示例。
在下文中一共展示了News::where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autocomplete
public function autocomplete()
{
$term = Request::input('term');
$search = News::where('nTitle', 'LIKE', '%' . $term . '%')->get();
foreach ($search as $item) {
$result[] = array('value' => $item->nTitle);
}
return Response::json($result);
}
示例2: news
/**
* Get the news entries tagged to me
* @param int $limit
* @return \Eloquent
*/
public function news($limit = 5)
{
if (count($this->newsLatest) >= 1) {
return $this->newsLatest;
}
// get class name that include this file (model name)
$parent = str_replace('AppModels', '', stripslashes(static::class));
$rows = DB::select("SELECT news.* FROM {$this->table}\n INNER JOIN news_tag ON news_tag.subject_id = {$this->table}.id\n INNER JOIN news ON news.id = news_tag.news_id\n WHERE {$this->table}.id = ? AND news_tag.subject_type LIKE ?\n GROUP BY news.id\n ORDER BY news.created_at DESC", [$this->id, '%' . $parent]);
$news = collect();
// filter active and get photos for entry
foreach ($rows as $k => $row) {
$item = News::where('id', $row->id)->active()->first();
if ($item) {
$item->images;
// get the images
$news->push($item);
}
}
$this->newsLatest = $news->take($limit);
return $this->newsLatest;
// old / default way
return $this->hasMany(NewsTag::class, 'subject_id', 'id')->where('subject_type', get_class($this))->with('news')->orderBy('created_at', 'DESC');
}
示例3: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$news = News::where('published_at', '<=', Carbon::now())->where('enabled', '=', '1')->orderBy('published_at', 'desc')->paginate(config('news.posts_per_page'));
return view('news.index', compact('news'));
}
示例4: frontendShow
public function frontendShow($id)
{
$result = News::find($id);
if (is_null($result)) {
$result = News::where('slug', $id)->get()->first();
}
$title = $result->title;
$result1 = DB::table('parent_menu')->get();
$siteTitle = Setting::where('name', 'title')->get();
if (count($siteTitle) > 0) {
$bah = $siteTitle->first()->value;
} else {
$bah = 'Website';
}
$footer = Setting::where('name', 'footer')->get();
if (count($footer) > 0) {
$footer = $footer->first()->value;
} else {
$footer = '(c) 2015, Ordent, All Right Reserved.';
}
return view('frontend.news-show', compact('result', 'title', 'result1', 'footer'));
}
示例5: postDelete
public function postDelete(Request $request)
{
$id = $request->input('id');
$ReturnData = [];
if (empty($id)) {
$this->error = true;
$this->error_message = "Dữ liệu không đúng, vui lòng thử lại";
goto next;
}
$CheckHasPost = Models\News::where('group_news_id', $id)->count();
if ($CheckHasPost == 0) {
try {
$rs = Models\Group_news::find($id)->delete();
} catch (Exception $e) {
$this->error = true;
$this->error_message = "Truy vấn lỗi, vui lòng thử lại";
goto next;
}
} else {
$this->error = true;
$this->error_message = "Vui lòng xóa hết bản tin trong chuyên mục này !";
goto next;
}
$this->error_message = "Thành công";
next:
return $this->ResponseData($ReturnData);
}