本文整理汇总了PHP中app\News::where方法的典型用法代码示例。如果您正苦于以下问题:PHP News::where方法的具体用法?PHP News::where怎么用?PHP News::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\News
的用法示例。
在下文中一共展示了News::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vacations
public function vacations($vacation)
{
if ($vacation == 'winter') {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Зима')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
} elseif ($vacation == 'spring') {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Весна')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
} elseif ($vacation == 'summer') {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Лето')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
} elseif ($vacation == 'autumn') {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Осень')->orderBy('programs.id', 'desc')->select('programs.id as id', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
} elseif ($vacation == 'weekend') {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Выходной')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
} elseif ($vacation == 'festival') {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Фестиваль')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
} else {
$programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
}
$all_news = News::where('active', '=', '1')->get();
$monthes = array(1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря');
if (Auth::check()) {
$user = Auth::user()->name;
} else {
$user = 'guest';
}
return view('index', ['programs' => $programs, 'monthes' => $monthes, 'all_news' => $all_news, 'user' => $user]);
}
示例2: index
public function index($token)
{
if ($token === 'W2Xcoiq28sLNasiszA819qgLk42CTc5b') {
$addressees = Model::all();
$news = News::getForDelivery();
$tenders = Tender::getForDelivery();
$vacancies = Vacancy::getForDelivery();
$shares = Share::getForDelivery();
$expert_advices = ExpertAdvice::getForDelivery();
foreach ($addressees as $addressee) {
$params['title'] = $addressee->locale . '_title';
$params['text'] = $addressee->locale . '_text';
$params['locale'] = $addressee->locale;
$addressee->news && count($news) ? $params['delivery']['news'] = $news : null;
$addressee->tenders && count($tenders) ? $params['delivery']['tenders'] = $tenders : null;
$addressee->vacancies && count($vacancies) ? $params['delivery']['vacancies'] = $vacancies : null;
$addressee->shares && count($shares) ? $params['delivery']['shares'] = $shares : null;
$addressee->expert_advices && count($expert_advices) ? $params['delivery']['expert_advices'] = $expert_advices : null;
if (isset($params['delivery'])) {
Mail::send('emails.delivery', $params, function ($message) use($addressee) {
$from_address = MailConfig::first();
$from_name = Config::get('mail.from');
$message->from($from_address->feedback_mail, $from_name['name']);
$message->to($addressee->email)->subject(trans('front-end' . DS . 'emails' . DS . 'delivery.subject'));
});
}
unset($params);
}
News::where('sended', 0)->update(['sended' => 1]);
Tender::where('sended', 0)->update(['sended' => 1]);
Vacancy::where('sended', 0)->update(['sended' => 1]);
Share::where('sended', 0)->update(['sended' => 1]);
ExpertAdvice::where('sended', 0)->update(['sended' => 1]);
}
}
示例3: viewNewsAction
public function viewNewsAction()
{
if (Request::has('id')) {
$news = News::where('id', '=', Request::input('id'))->first();
return view('base.view_news', ['news' => $news]);
}
}
示例4: getView
public function getView(Request $request)
{
$news = News::where("slug", $request->get('slug'))->first();
if ($news->image->count()) {
$news->images = $news->image->name;
}
return response()->json($news);
}
示例5: index
public function index(Request $request)
{
if ($request->input('tag') == '全部动态' || $request->input('tag') == null) {
return view('news.index')->withNavSelection(3)->withTagSelection("全部动态")->withNews(News::paginate(10));
} else {
return view('news.index')->withNavSelection(3)->withTagSelection($request->input('tag'))->withNews(News::where('tag', $request->input('tag'))->paginate(10));
}
}
示例6: newsShow
public function newsShow($slug)
{
$visitor = News::where('is_hide', 0)->where('slug', $slug)->where("created_at", "like", $this->year . "%")->firstOrFail();
$visitor->views++;
$visitor->save();
$news = News::where('is_hide', 0)->where('slug', $slug)->where("created_at", "like", $this->year . "%")->firstOrFail();
return view('conference_information.detail_news', compact('news'))->with('year', $this->curYear);
}
示例7: getArticle
public function getArticle($slug)
{
try {
$article = News::where('slug', '=', $slug)->firstOrFail();
return view('news-single', ['post' => $article]);
} catch (\Exception $e) {
return redirect('/news');
}
}
示例8: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$newscount = News::where('id', '!=', 'null')->count();
$chartercount = Charters::where('id', '!=', 'null')->count();
$userscount = User::where('id', '!=', 'null')->count();
$categories = \DB::table('news_categories')->lists('name', 'id');
$publisher = \DB::table('users')->lists('name', 'id');
return view('backend.home', compact('newscount', 'userscount', 'chartercount'))->with(['categories' => $categories, 'publisher' => $publisher]);
}
示例9: show
public function show($id)
{
if ($oNews = News::where('id', $id)->with(['comments'])->get()) {
$aRet = ['success' => 'true', 'news' => $oNews->toArray()];
} else {
$aRet = ['success' => 'false', 'error' => 'cant find news with this id'];
}
return response()->json($aRet);
}
示例10: index
public function index(Request $request)
{
$tag = $request->input('tag');
if ($tag == null || $tag == "全部分类") {
return view('admin.news.index')->withNews(News::paginate(10))->withTag($tag);
} else {
return view('admin.news.index')->withNews(News::where('tag', $tag)->paginate(10))->withTag($tag);
}
}
示例11: delete
public function delete($id)
{
$entry = News::find($id);
if (isset($entry)) {
News::where('id', $id)->update(array('trash' => 1));
return \Redirect::route('news')->with('success', $entry->title . ' deleted succesfully!');
} else {
return \Redirect::route('news')->with('error', 'Failed to delete, invalid credentials.');
}
}
示例12: getIndex
public function getIndex()
{
$banners = File::where('img_type', 'banner')->where("created_at", "like", $this->year . "%")->get();
$speakers = Speaker::where("created_at", "like", $this->year . "%")->limit(4)->get();
$cooperations = File::where('img_type', 'cooperation')->where("created_at", "like", $this->year . "%")->get();
$supporteds = File::where('img_type', 'supported')->where("created_at", "like", $this->year . "%")->get();
$organizeds = File::where('img_type', 'organized')->where("created_at", "like", $this->year . "%")->get();
$news = News::where('is_hide', 0)->where("created_at", "like", $this->year . "%")->orderBy('id', 'desc')->limit(4)->get();
return view('frontend.home.index', compact('banners', 'speakers', 'cooperations', 'supporteds', 'organizeds', 'news'))->with('year', $this->curYear);
}
示例13: storeComment
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function storeComment(Comments $comment, CreateCommentRequest $request)
{
/*$this->validate($request, [
'nama' => 'required',
'email' => 'required|email',
'komentar' => 'required'
]);*/
$news_slug = News::where('id', $request->input('news_id'))->first()->slug;
$comment->create($request->all());
return redirect()->route('news_path', [$news_slug, '#comments-box']);
}
示例14: comment
public function comment($slug)
{
$news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get();
$news = News::where('slug', '=', $slug)->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news.category', 'news.s_content', 'news.content', 'users.name as publisher', 'news.image', 'news.created_at')->get();
$com_id = News::first();
$comment = new Comment();
$comment->body = \Input::get('comment');
$comment->poster = \Input::get('author');
$comment->commentable_id = $com_id->id;
$com_id->comments()->save($comment);
return \Redirect::back()->with(['news' => $news, 'news2' => $news2]);
}
示例15: postDelete
public function postDelete(Request $request, $id)
{
$item = News::where('id', $id)->first();
if ($item != null) {
$item->delete();
$msg = "Новость \"" . $item->title . "\" удалена.";
return redirect('admin/news')->with('msg', $msg);
} else {
$msg = "Новости с id = " . $id . " не существует.";
return redirect('admin/news')->with('msg', $msg);
}
}