/** * Get all of the articles for a given user. ** * * @return mixed */ public function forUser() { if ($this->user->is_admin) { return $this->article->all()->sortBy('created_at'); } return $this->article->where('user_id', $this->user->id)->orderBy('created_at', 'asc')->get(); }
/** * Return all all articles */ public function getIndex(Request $request) { $articles = Article::where('active', 1); /** * Filter by category */ if ($request->has('category')) { $filter_category = $request->get('category'); $category = Category::find($filter_category); // if there is no category with this name if (!$category) { return response()->json(['code' => '404', 'message' => 'There is no category with this id'], 404); } // if category is exists $articles = $category->articles(); } /** * Filter by order */ if ($request->has('order')) { $fitler_order = $request->get('order'); if ($fitler_order == 'desc' || $fitler_order == 'asc') { $articles->orderBy('views', $fitler_order); } } return response()->json(['code' => '200', 'data' => $articles->get()], 200); }
public function show($slug) { // $article = Article::with('authors', 'tags', 'pictures', 'videos', 'category')->findOrFail($id); $article = Article::where(['articles.slug' => $slug])->with('authors', 'tags', 'pictures', 'videos', 'category')->first(); $pictures = $article->picturesArray; return view('article.show', compact('article', 'pictures')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($slug) { $article = Article::where('slug', $slug)->firstOrFail(); $articleSide = DB::select("select title, slug, image_lead\n from articles\n WHERE ID !='{$article->id}' limit 5;"); $googlePhrahes = Google::limit(30)->orderBy('id', 'DESC')->get(); return view('article', compact('article', 'articleSide', 'googlePhrahes')); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); \Route::bind('articleslug', function ($value) { return \App\Article::where('slug', $value)->with('user')->with('writer')->with('screenshot.image')->firstOrFail(); }); }
public function showArticle($id) { $article = Article::findOrFail($id); $news = Article::where('id', '>', $article->id)->orderBy('id', 'DESC')->take(NEW_OLD_ARTICLE); $olds = Article::where('id', '<', $article->id)->orderBy('id', 'DESC')->take(NEW_OLD_ARTICLE); return view('frontend.articles.main')->with(compact('news', 'article', 'olds')); }
public function index(Article $article) { // $articles = $article->getArticles(); $articles = Article::where('active', '=', 1)->where('published_at', '<=', Carbon::now())->latest('published_at')->simplePaginate(4); $articles->setPath('articles'); return view('articles.articles')->with('articles', $articles); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { $router->bind('article', function ($slug) { return Article::where('slug', $slug)->firstOrFail(); }); parent::boot($router); }
public function index() { $choosenLang = \Session::get('locale'); $tags = Tag::where('lang', '=', $choosenLang)->get(); $articles = Article::where('lang', '=', $choosenLang)->paginate(2); return view('index', compact('articles', 'tags')); }
public function getArticle($cate, $arti) { $arti = substr($arti, 0, -5); //cắt chuối ".html" cuối article alias $category = Category::where("category_alias", $cate)->first(); //lấy category đầu tiên có alias bằng tham số category alias $listCategory = Category::all(["id", "category_alias", "category_name"])->toArray(); $allArticles = Article::all(["id", "title", "alias", "summary", "content", "image", "category_id", "author", "created_date"])->where('category_id', $category["id"])->toArray(); //lấy tất cả bài viết trong category if ($category != null) { $message = ""; $category_name = $category["category_name"]; if (count($allArticles) == 0) { $message = 'Không có bài viết nào.'; } else { $article = Article::where("alias", $arti)->first(); if ($article != null) { $relateArticles = Article::where('category_id', $category["id"])->where("id", '!=', $article["id"])->orderBy('created_date', 'desc')->get()->take(2)->toArray(); return view('front.blog.article', compact('listCategory', 'relateArticles', 'message', 'category_name', 'article', 'mess')); } else { $message = "Không tìm thấy bài viết phù hợp"; return view('front.blog.error', compact('listCategory', 'message', 'category_name')); } } return view('blog.index', compact('listCategory', 'message', 'category_name')); } }
public function detail($slug, Request $request) { $slug = Input::get('slug'); $articleModel = new Article(); $article = $articleModel->where('slug', $slug)->firstOrFail(); return $article; }
public function article($categorykey, $articlekey) { $article = Article::where('key', $articlekey)->first(); if ($article != null) { // metadata $site_title = $article->name . ' - ' . Config::findByKey('site_title')->first()->value; SEOMeta::setTitle($site_title); SEOMeta::setDescription($article->meta_description); SEOMeta::addKeyword([$article->meta_keywords]); SEOMeta::addMeta('article:published_time', $article->created_at->toW3CString(), 'property'); if (isset($article->categories->first()->name)) { SEOMeta::addMeta('article:section', $article->categories->first()->name, 'property'); } OpenGraph::setTitle($site_title); OpenGraph::setDescription($article->meta_description); OpenGraph::setUrl(route('article', ['categorykey' => $categorykey, 'articlekey' => $articlekey])); OpenGraph::addProperty('type', 'article'); OpenGraph::addProperty('locale', app()->getLocale()); OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']); OpenGraph::addImage($article->getFirstAttachment()); OpenGraph::addImage($article->attachments->lists('path')); OpenGraph::addImage(['url' => Image::url($article->getFirstAttachment(), 300, 300, array('crop')), 'size' => 300]); // end metadata return view('frontend.sites.article', compact('article')); } else { return view('errors.404'); } }
public function Home() { $flash = Event::where('start_date', '<=', new \Datetime())->where('end_date', '>=', new \Datetime())->orderBy('id', 'desc')->take(1)->get()->first(); $articles = Article::where('id', '!=', isset($flash) ? $flash->article->id : 0)->orderBy('publish_at', 'desc')->orderBy('id', 'desc')->take(5)->get(); $ffttNews = FFTTNew::orderBy('date', 'desc')->take(3)->get(); return view('front.home', array('articles' => $articles, 'NewsFlash' => $flash, 'ffttNews' => $ffttNews)); }
/** * Bootstrap the application services. * * @return void */ public function boot(Router $router) { $router->bind('article', function ($id) { return \App\Article::where('slug', $id)->first(); }); parent::boot($router); }
public function index($username) { $articles = Article::where('user_id', '=', auth()->user()->id)->orderBy('created_at', 'desc')->get(); $categories = Category::all(); $tags = Tag::all(); return view('articles.new')->with(['articles' => $articles, 'categories' => $categories, 'tags' => $tags]); }
private function insertArticles($filename) { $i = 0; $filename = 'storage/app/' . $filename; Excel::load($filename, function ($reader) use($i) { $results = $reader->get(); foreach ($results as $article) { $NoEstaEnLaBD = is_null(Article::where('product_code', $article['codigo'])->first()); if ($NoEstaEnLaBD) { // si el articulo _NO_ se encuentra en la base de datos if (is_null($article['serializable'])) { $serializable = 0; } else { $serializable = $article['serializable']; } $a = Article::create(['product_code' => $article['codigo'], 'unit' => $article['ub'], 'name' => $article['descripcion'], 'barcode' => $article['barcode'], 'fav' => $article['fav'], 'serializable' => $serializable, 'active' => $article['activo']]); $i++; } else { // si el codigo se encuentra en la base de datos } } }); // Fin del Excel::load return $i; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $keyword = Input::get('keyword'); $results = Article::where('title', 'LIKE', '%' . $keyword . '%')->get(); //dd($results); return view('searchresults', compact('results')); }
/** * article update. * * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $data = $request->all(); // dd($data); Article::where('id', $id)->update($data); return response()->json(['message' => '更新成功'], 201); }
public function search() { $searchKeyword = Request::input('keyword'); $brand_id = Request::input('brand_id'); $brand_model_id = Request::input('brand_model_id'); $part_type_id = Request::input('part_type_id'); $public = Request::input('public'); if ($public == 'all') { $public = null; } $articles = Article::where('name', 'like', '%' . $searchKeyword . '%')->where(function ($query) use($brand_id) { if ($brand_id != '') { $query->where('brand_id', $brand_id); } })->where(function ($query) use($brand_model_id) { if ($brand_model_id != '') { $query->where('model_id', $brand_model_id); } })->where(function ($query) use($part_type_id) { if ($part_type_id != '') { $query->where('part_type_id', $part_type_id); } })->where(function ($query) use($public) { if (isset($public)) { $query->where('public', $public); } })->with('articleType', 'brand', 'model', 'partType')->orderBy('name', 'asc')->get(); $outputView = view('backoffice.articles.partials.articlesTable')->with(compact('articles'))->render(); return $outputView; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($idlevel, $level, $idspeciality, $speciality, $idmaterial, $material, $idlesson, $lesson) { $newsallarticles = Article::where('stat', '=', 'nouvelles')->orderBy('id', 'desc')->take(3)->get(); $bacallarticles = Article::where('stat', '=', 'apres-bac')->orderBy('id', 'desc')->take(3)->get(); $speciality = str_replace('-', ' ', $speciality); $material = str_replace('-', ' ', $material); $lesson = str_replace('-', ' ', $lesson); $lessonnames = Lesson::where('id', '=', $idlesson)->get(); $specialitynames = Category::where('id', '=', $idspeciality)->get(); $alllessons = Lesson::groupBy('categories_id')->orderBy('id', 'desc')->get(); $rounds1 = Lesson::where('round', '=', '1ere-session')->get(); $rounds2 = Lesson::where('round', '=', '2eme-session')->get(); $fullcat = Category::get(); $all = Category::where('parent', '=', 0); $level = str_replace('-', ' ', $level); $levelnames = Category::where('id', '=', $idlevel)->get(); $materialnames = Category::where('id', '=', $idmaterial)->get(); foreach ($lessonnames as $lessonname) { $ar_lessonname = $lessonname->ar_title; } foreach ($specialitynames as $specialityname) { $ar_specialityname = $specialityname->ar_name; } foreach ($levelnames as $levelname) { $ar_levelname = $levelname->ar_name; } foreach ($materialnames as $materialname) { $ar_materialname = $materialname->ar_name; } return view(proj . '.resumes', ['title' => $ar_lessonname, 'ar_materialname' => $ar_materialname, 'ar_levelname' => $ar_levelname, 'rounds1' => $rounds1, 'rounds2' => $rounds2, 'asccat' => $all->get(), 'allcat' => $all->orderBy('id', 'desc')->get(), 'fullcat' => $fullcat, 'idlevel' => $idlevel, 'idspeciality' => $idspeciality, 'idmaterial' => $idmaterial, 'idlesson' => $idlesson, 'level' => $level, 'newsallarticles' => $newsallarticles, 'bacallarticles' => $bacallarticles, 'alllessons' => $alllessons, 'ar_lessonname' => $ar_lessonname, 'lesson' => $lesson, 'material' => $material, 'ar_specialityname' => $ar_specialityname, 'speciality' => $speciality]); }
public function articlesCat($cat) { $articles = Article::where('category_id', $cat)->get(); if (count($articles) == 0) { return response()->json(['error' => ['message' => 'No existen articulos en esta Categoría']], 404); } return response()->json($articles, 200); }
/** * @param $type * @return \Illuminate\View\View */ public function getArticles($type) { $mod = Article::where('article_type', '=', $type)->orderBy('updated_at', 'desc'); $articles = $mod->paginate(3); // $this->assign('articles',$articles); // return $this->display('home.index'); return View('home.index', ['articles' => $articles]); }
/** * Returns a JSON response of a requested user. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $user = \App\User::where(['name' => $request['name']])->get(); $id = $user[0]['id']; $articles = \App\Article::where(['user_id' => $id])->get(); $profile = \App\Profile::where(['user_id' => $id])->get()->first(); return response()->json(['error' => false, 'user' => $user, 'articles' => $articles, 'profile' => $profile]); }
public function index($username) { if ($username == 'admin') { return redirect('/dashboard'); } $user = User::where('username', '=', $username)->first(); $articles = Article::where('user_id', '=', $user->id)->paginate(8); return view('user.articles')->with(['user' => $user, 'articles' => $articles]); }
public function index() { if (Request::has('filterBycategory_id')) { $articles = Article::where('category_id', Request::input('filterBycategory_id'))->get(); } else { $articles = Article::latest()->get(); } return view('articles.index', compact('articles')); }
/** * Handle the event. * * @param UserWasDeleted $event * @return void */ public function handle(UserWasDeleted $event) { // Delete everything the user created Article::where('user_id', $event->user_id)->delete(); Photo::where('user_id', $event->user_id)->delete(); PhotoAlbum::where('user_id', $event->user_id)->delete(); Video::where('user_id', $event->user_id)->delete(); VideoAlbum::where('user_id', $event->user_id)->delete(); }
public static function pn($id) { $article = array(); $classify = Article::find($id)->classify; $article['prev'] = Article::where('classify', '=', $classify)->where('id', '<', $id)->orderBy('created_at', 'DESC')->first(); $article['next'] = Article::where('classify', '=', $classify)->where('id', '>', $id)->orderBy('created_at', 'DESC')->first(); $article['about'] = Article::where('classify', '=', $classify)->skip(0)->take(6)->get(); return $article; }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // // versione modificata $router->bind('articles', function ($id) { return \App\Article::where('id', $id)->firstOrFail(); }); parent::boot($router); }
public static function byTag($value) { $article = Article::where('tag', $value)->first(); if ($article == null) { $article = new Article(); $article->title = ''; $article->content = '暂无内容'; } return $article; }
public function overview() { $data['inbox_count'] = Email::where('user_id', Auth::id())->where('box_id', 1)->count(); //todo: if you want to write articles, contact us $articles = Article::where('user_id', Auth::id())->orderBy('id', 'asc')->get(); $sites = Auth::user()->sites()->get(); $professions = Auth::user()->professions()->get(); $classifieds = Classified::where('user_id', Auth::id())->orderBy('id', 'desc')->get(); return view('dashboard.overview', compact('data', 'articles', 'sites', 'professions', 'classifieds')); }