Example #1
0
 /**
  * Страница новости
  * @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]);
 }
Example #2
0
 /**
  * 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();
 }
Example #3
0
 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);
 }
Example #4
0
 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);
 }
Example #5
0
 /**
  * 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);
 }
 /**
  * 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);
     });
 }
Example #7
0
 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'));
 }
 public static function findSpecialArticle(SpecialArticle $specialArticle) : Article
 {
     return Cache::rememberForever("article.specialArticle.{$specialArticle}", function () use($specialArticle) {
         return Article::where('technical_name', $specialArticle)->firstOrFail();
     });
 }
 /**
  * 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'));
 }
 /**
  * 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]);
 }
 public function news()
 {
     $articles = Article::where('active', 1)->latest()->get();
     return view('home.news', ['articles' => $articles]);
 }
Example #12
0
        // 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;
 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']);
 }
 public function getNewsBriefs()
 {
     return Article::where('page_id', 13)->where('published', 1)->orderBy('date_created', 'DESC')->get();
 }
Example #15
0
 public function delete($id)
 {
     Article::where('id', '=', $id)->update(array('status' => 0));
     return Redirect::back()->with('message', 'Article has been updated successfully!');
 }
Example #16
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $slug
  * @return \Illuminate\Http\Response
  */
 public function edit($slug)
 {
     $this->setMetaTitle('Edit Article');
     $article = Article::where('slug', '=', $slug)->firstOrFail();
     return view('articles.edit', compact('article'));
 }