本文整理汇总了PHP中app\models\Article::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::where方法的具体用法?PHP Article::where怎么用?PHP Article::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Article
的用法示例。
在下文中一共展示了Article::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: article
/**
* Страница новости
* @param Request $request
* @param $alias
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function article(Request $request, $alias)
{
$article = Article::where('alias', $alias)->first();
if (is_null($article)) {
abort(404, 'Новость не найдена');
}
return view('pages/article', ['article' => $article]);
}
示例2: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
//定时任务
$schedule->call(function () {
Log::info('1111111');
Article::where('published_time', '<', date('Y-m-d H:i:s'))->update(['is_checked' => 1]);
})->everyMinute();
}
示例3: brokers
public function brokers()
{
$category = Role::find(Config::get('constants.ROLE_BROKER'));
$results = Article::where('category_id', '=', $category->id)->paginate(18);
if (Request::ajax()) {
return Response::json(View::make('articles.category')->withResults($results)->render());
}
return View::make('articles.category')->withCategory($category)->withArticles($results);
}
示例4: detail
public function detail($slag)
{
$article = Article::where('slag', $slag)->findOrFail();
if (!Article::find($article->id + 1)) {
$article->max = true;
} else {
$article->max = false;
}
$categories = Category::all();
return view('article.detail')->withArticle($article)->withCategories($categories)->withId($id);
}
示例5: index
/**
* Create a new controller instance.
*
* @return void
*/
public function index(Request $request)
{
$projects = Article::where('type', 'page')->orderBy('sort_order')->get();
foreach ($projects as $project) {
$services = explode(',', $project->services);
$services_list = '<ul>';
foreach ($services as $service) {
$services_list .= '<li>' . $service . '</li>';
}
$services_list .= '</ul>';
$project->services = $services_list;
$project->logos = ProjectLogo::where('article_id', $project->id)->get();
$project->images = ProjectImage::where('article_id', $project->id)->get();
}
$email = Option::where('key', 'contact.email')->first()->value;
$phone = Option::where('key', 'contact.phone')->first()->value;
$data = array('projects' => $projects, 'email' => $email, 'phone' => $phone);
return view('portfolio', $data);
}
示例6: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
parent::boot();
Route::bind('article', function ($slug) {
if (!Auth::user()) {
return Article::published()->slug($slug)->first();
}
return Article::where('slug', $slug)->first() ?: Article::findOrFail((int) $slug);
});
Route::bind('tag', function ($slug) {
if (!Auth::user()) {
return Tag::slug($slug)->first();
}
return Tag::where('slug', $slug)->first() ?: Tag::findOrFail((int) $slug);
});
Route::bind('page', function ($id) {
return Page::find($id);
});
}
示例7: show
public function show($id)
{
Article::where('id', $id)->increment('views');
//阅读量加1
$article = Article::with(['comments' => function ($query) {
$query->take(10);
}])->find($id);
// dd($article);
$views = Article::where('author_id', $article->author_id)->where('author_type', $article->author_type)->sum('views');
$comments_count = Comment::where('article_id', $id)->count();
$hots = Article::orderBy('views', 'desc')->take(10)->get();
$is_like = false;
$is_collection = false;
$is_follow = false;
if ($this->login_user) {
$is_like = Like::where('user_id', $this->login_user->id)->where('like_type', 'article')->where('like_id', $id)->first();
$is_collection = Collection::where('user_id', $this->login_user->id)->where('collection_type', 'article')->where('collection_id', $id)->first();
$is_follow = DB::table('user_follow')->where('user_id', $this->login_user->id)->where('follow_id', $article->author_id)->first();
}
return view('front.article.index', compact('article', 'views', 'comments_count', 'hots', 'is_like', 'is_collection', 'is_follow'));
}
示例8: findSpecialArticle
public static function findSpecialArticle(SpecialArticle $specialArticle) : Article
{
return Cache::rememberForever("article.specialArticle.{$specialArticle}", function () use($specialArticle) {
return Article::where('technical_name', $specialArticle)->firstOrFail();
});
}
示例9: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$articles = Article::where('publish_time', '<=', Carbon::now())->orderBy('publish_time', 'desc')->paginate(15);
return view('nweaver.commuity', compact('articles'));
}
示例10: getDraft
/**
* Responds to requests to GET /article/draft/{id}
*
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getDraft($id)
{
$article = Article::where('user_id', '=', Auth::id())->where('state', '=', Article::DRAFT)->where(function ($q) use($id) {
$q->where('slug', '=', $id)->orWhere('id', '=', $id);
})->first();
if (!$article) {
return redirect()->action('ArticleController@getCreate');
}
$tags = implode(',', array_flatten($article->tags()->get(['name'])->toArray()));
return view('articles.create', ['article' => $article, 'tags' => $tags]);
}
示例11: news
public function news()
{
$articles = Article::where('active', 1)->latest()->get();
return view('home.news', ['articles' => $articles]);
}
示例12: function
// save方法
$data = \App\Models\Articles::where('id', '=', 11)->first();
$data->article_title = 'update test -3-.';
$data->feature = true;
$data->save();
}]);
Route::get('delete', ['as' => 'ORM.delete', function () {
$data = \App\Models\Articles::find(2);
$data->delete();
\App\Models\Articles::destroy(19, 20);
}]);
});
Route::get('test', function () {
// $data = \App\Models\Article::find(5);
$data1 = \App\Models\Article::all();
$data2 = \App\Models\Article::where('id', '>', 8);
$data3 = \App\Models\Article::orderBy('id', 'DESC');
dd([$data1, $data2, $data3]);
});
/*
Route::get('hello', function(){
return "Hello World!";
});
Route::get('post/{id}', function($id) {
return "id:".$id;
})->where('id', '[0-9]+');
// route name
Route::get('post2/{id?}', ['as' => 'post2.show', function($id = 0) {
return "id:".$id;
示例13: updateBean
public function updateBean(Request $request)
{
$customer = \Helper::getCustomer();
if (!$customer) {
return response()->json(['result' => '-1']);
}
/*if>*/
if (!$customer->is_registered) {
return response()->json(['result' => '-1']);
}
/*if>*/
$article = Article::where('id', $request->input('id'))->first();
\Analyzer::updateArticleStatistics($customer->id, $article->type_id);
\Analyzer::updateBasicStatistics($customer->id, AnalyzerConstant::CUSTOMER_ARTICLE);
\EnterpriseAnalyzer::updateArticleStatistics($article->type_id);
\EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_ARTICLE);
if (\DailyAnalyzer::getDailyItemCount($customer->id, AnalyzerConstant::CUSTOMER_DAILY_ARTICLE)) {
\DailyAnalyzer::updateDailyItemCount($customer->id, AnalyzerConstant::CUSTOMER_DAILY_ARTICLE);
return response()->json(['result' => '-1']);
}
\DailyAnalyzer::updateDailyItemCount($customer->id, AnalyzerConstant::CUSTOMER_DAILY_ARTICLE);
\BeanRecharger::executeEducation($customer);
return response()->json(['result' => '1']);
}
示例14: getNewsBriefs
public function getNewsBriefs()
{
return Article::where('page_id', 13)->where('published', 1)->orderBy('date_created', 'DESC')->get();
}
示例15: delete
public function delete($id)
{
Article::where('id', '=', $id)->update(array('status' => 0));
return Redirect::back()->with('message', 'Article has been updated successfully!');
}