Exemple #1
0
 /**
  * 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();
 }
 public function index(Request $request)
 {
     $output = Article::all();
     //        $url = $request->url();
     //        dd($url);
     return view('articles.index', compact('output'));
 }
Exemple #3
0
 public function run()
 {
     $article = Article::all()->first();
     DB::table('places')->delete();
     $place = Place::create(array('name' => 'Innocenti Evasioni', 'url' => 'http://www.innocentievasioni.com/', 'address' => 'Via Privata della Bindellina, 20155 Milano', 'lat' => '45.492522', 'lng' => '9.149578', 'status' => Place::GEOLOCALIZED));
     $article->places()->attach($place);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $teachers = Teacher::topN(6);
     $articles = Article::all();
     $categories_in_pane = ArticleCategory::all();
     return response()->view('site.colabor', array('teachers' => $teachers, 'other_articles' => $articles, 'categories_in_pane' => $categories_in_pane));
 }
 public function welcome()
 {
     $id = 1;
     $parent = Cate::select('id', 'name', 'parent_id')->where('catetype_id', $id)->get()->toArray();
     $article = Article::all();
     return view('welcome', compact('parent', 'article'));
 }
 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 index()
 {
     $articles = Article::all();
     if (Request::wantsJson()) {
         return $articles;
     }
     return view('articles.index', compact('articles'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //		return view('Admin')->withPages(Page::all());
     //		return view('Admin',['pages'=>Page::all()]);
     return view('Admin')->with('pages', Page::all())->with('articles', Article::all());
     //		$pages['pages'] = Page::all();
     //		return view('Admin',$pages);
 }
 public function listArticle()
 {
     $article = new Article();
     $list = $article->all()->toArray();
     return view('admin.article.index')->with('listArticle', $list);
     //có thể có cách khác assign biến ra
     //return view('article.index',compact('list')); <== phần này ở ngoài sẽ đọc luôn cái list
 }
 public function testCreateAndList()
 {
     $articleCount = 10;
     for ($i = 1; $i <= $articleCount; $i++) {
         Article::create(['title' => 'subject ' . $i, 'body' => 'body ' . $i]);
     }
     $articles = Article::all();
     $this->assertEquals($articleCount, count($articles));
 }
Exemple #11
0
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $articleCount = Article::all()->count();
     $partTypeCount = PartType::all()->count();
     $brandsCount = Brand::all()->count();
     $modelCount = BrandModel::all()->count();
     // dd($articleCount);
     return view('home')->with(['articleCount' => $articleCount, 'partTypeCount' => $partTypeCount, 'brandsCount' => $brandsCount, 'modelCount' => $modelCount]);
 }
 public function index()
 {
     if (!Auth::check()) {
         return redirect('/');
     }
     $users = User::all();
     $articles = Article::all();
     return view('auth.profil', compact('users', 'articles'));
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('partials._blog-aside', function ($view) {
         $view->with('postDate', Article::all()->groupBy(function ($date) {
             return Carbon::parse($date->created_at)->format('M-y');
         }));
         $view->with('tags', Tag::all());
     });
 }
 /**
  * Test the localized model.
  */
 public function testLocales()
 {
     $locales = ['en', 'nl', 'fr', 'de'];
     $this->visit('/create')->see('Article created');
     $this->assertCount(1, Article::all());
     $this->assertCount(count($locales), ArticleTranslation::all());
     foreach ($locales as $locale) {
         $this->visit("/{$locale}")->see("Title {$locale}")->see("Text {$locale}");
     }
 }
 public function index()
 {
     $articles = Article::all();
     $tutorials = Tutorial::all();
     $users = User::where('is_sitepoint', false)->get();
     $meetups = Meetup::all();
     $projects = Project::all();
     $bugs = Bugreport::all();
     return view('backend.pages.dashboard', compact('articles', 'tutorials', 'users', 'meetups', 'projects', 'bugs'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $med = Meds::where('slug', $slug)->firstorFail();
     $czynnik = $med->skladnik_aktywny;
     $medLike = Meds::where('skladnik_aktywny', $czynnik)->limit(6)->get();
     $czynnik2 = $med->skladnik_aktywny2;
     $medLike2 = Meds::where('skladnik_aktywny2', $czynnik2)->limit(6)->get();
     $articleSide = Article::all()->random(2);
     return view('show', compact('med', 'medLike', 'czynnik', 'medLike2', 'czynnik2', 'articleSide'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $article = new Article();
     $article->body = $request->input('body');
     $article->title = $request->input('title');
     $article->save();
     $articles = Article::all();
     dd($articles);
 }
Exemple #18
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $active = 'articles';
     $articles = Article::all();
     if ($article = Article::find($id)) {
         return view('articles.show', compact('article', 'active'));
     } else {
         Request::session()->flash('Error', 'this article not found Please ty again');
         return view('articles.index', compact('articles', 'active'));
     }
 }
 public function index()
 {
     // /*1. 获取分类*/
     // $navs = Nav::getnav()->get()->toArray();
     // $navIndex = array();
     // // dd($navs);
     // $this->parseArray($navs);
     /*获取文章*/
     $articles = Article::all();
     $returnData = ['articles' => $articles];
     return view('index.index')->with($returnData);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['nom' => 'required|max:255|min:2', 'description' => 'required|max:255', 'code' => 'required|max:255']);
     $article = new Article();
     $article->nom = Input::get('nom');
     $article->description = Input::get('description');
     $article->code = Input::get('code');
     $article->save();
     $articles = Article::all();
     $data_validations = ["Votre article a été ajouté"];
     return view('article/index', compact('articles', 'data_validations'));
 }
 public function showTable(Request $request)
 {
     //
     //for users table
     if ($request->url() == url('backend/tableusers')) {
         $users_record = User::all();
         return view('backend/tableusers', compact('users_record'));
     }
     //for articles table
     if ($request->url() == url('backend/tablearticles')) {
         $articles_record = Article::all();
         return view('backend/tablearticles', compact('articles_record'));
     }
 }
Exemple #22
0
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $articles = Article::all();
     foreach ($articles as $article) {
         $article_ids[] = $article->id;
     }
     //删除与文章关联的tag
     $tag->articles()->detach($article_ids);
     if ($tag->delete()) {
         return redirect('admin/tags')->with('message', '删除成功!');
     } else {
         return back()->withInput()->with('errors', '保存失败!');
     }
 }
Exemple #23
0
 public function buildForm()
 {
     $ArticleCategories = ArticleCategory::all(['id', 'name'])->sortBy('name')->pluck('name', 'id')->toArray();
     $ArticleMasters = Article::all(['id', 'title'])->sortBy(['master', 'title'])->pluck('title', 'id')->toArray();
     $this->add('title', 'text', Helper::buildFormAddWithIcon('Provide a title', 'title', 'fa fa-external-link', 'success', 'required|min:4|max:80'));
     $this->add('description', 'textarea', Helper::buildFormAddWithIcon('Add a description (needed for Facebook, twitter etc.) Min 20, max 500 characters', 'description', 'fa fa-facebook', 'success', 'required|min:20|max:500', '', 'vendor.laravel-form-builder.textarea-icon'));
     $this->add('url', 'url', Helper::buildFormAddWithIcon('Is the article linked? Here you can provide a link (optional)', 'url', 'fa fa-at', 'success', '', 'http://'));
     $this->add('picture_url', 'url', Helper::buildFormAddWithIcon('This is a picture URL needed for facebook and other API\'s (if you don\'t have the URL yet, upload and update)', 'url', 'fa fa-file-picture-o', 'success'));
     $this->add('body', 'textarea', Helper::buildFormAddWithIcon('Write your article:', 'body', 'fa fa-pencil-square-o', 'success', 'required|min:10', '', 'vendor.laravel-form-builder.textarea-icon'));
     $this->add('categories', 'select', array_merge(['choices' => $ArticleCategories, 'selected' => function () {
         return $this->model->categories->pluck('id')->toArray();
     }], Helper::buildFormAddWithIcon('Choose the categories of this article (required)', 'categories[]', '', 'success', '', '', 'vendor.laravel-form-builder.select-icon', false, true)));
     $this->add('published_at', 'date', Helper::buildFormAddWithIcon('Published at', 'published_at', 'fa fa-calendar', 'success', 'date_format:Y-m-d', date('Y-m-d'), '', true));
     $this->add('can_comment', 'checkbox', ['label' => 'Users can leave a comment']);
     $this->add('auto_comments', 'checkbox', ['label' => 'Comments are automatically approved']);
     $this->add('strip_tags', 'checkbox', ['label' => 'Check this if copy/pasted from a website']);
     $this->add('master', 'select', ['choices' => $ArticleMasters, 'empty_value' => '--- Select master article', 'property' => 'title', 'label' => 'If this article is linked to another article, make your choice here:']);
 }
Exemple #24
0
 public function loadCategory()
 {
     $categories = Category::all();
     $articles = Article::all();
     // link the category id and the its related articles
     $articlesNumber = [];
     foreach ($categories as $category) {
         if (CategoriesController::getArticleNumber($category->id) != null) {
             $articlesNumber[$category->id] = CategoriesController::getArticleNumber($category->id)[0]->article_number;
         } else {
             $articlesNumber[$category->id] = '0';
         }
     }
     if (User::getCurrentUser() != null) {
         $is_manager = User::getCurrentUser()->is_manager;
     } else {
         $is_manager = false;
     }
     return compact('categories', 'articles', 'articlesNumber', 'images', 'is_manager');
 }
 /**
  * Display sitemap.xml
  *
  * @return Response
  */
 public function index()
 {
     $sitemap = App::make("sitemap");
     if (!$sitemap->isCached()) {
         // main page
         $home = URL::to('/');
         $sitemap->add($home, date('c', time()), '1.0', 'daily');
         $perPage = 15;
         // tags
         foreach (config('sitemap.tags') as $tag => $label) {
             $url = route('tag', $tag);
             $sitemap->add($url, date('c', time()), '0.7', 'weekly');
             // pages of tag
             $pages = ceil(Article::byTag($tag)->count() / $perPage);
             if ($pages > 1) {
                 for ($page = 2; $page <= $pages; $page++) {
                     $sitemap->add("{$url}/page/{$page}", date('c', time()), '0.7', 'weekly');
                 }
             }
         }
         // all posts
         $posts = Article::all();
         foreach ($posts as $post) {
             if ($post->path) {
                 $url = route('post', $post->path);
             } else {
                 $url = route('post_by_id', $post->id);
             }
             $date = max(strtotime($post->created_at), strtotime($post->updated_at));
             $sitemap->add($url, date('c', $date), '0.9', 'daily');
         }
         // archive pages
         $pages = ceil(count($posts) / $perPage);
         if ($pages > 1) {
             for ($page = 2; $page <= $pages; $page++) {
                 $sitemap->add("{$home}/page/{$page}", date('c', time()), '0.8', 'daily');
             }
         }
     }
     return $sitemap->render('xml');
 }
Exemple #26
0
 /**
  * A basic test example.
  *
  * @return void
  */
 public function testSeedDatabase()
 {
     $articles = \App\Article::all();
     if ($articles->count() == 0) {
         echo "\nFiling the Users tables\n";
         factory(App\User::class, 20)->create()->each(function ($u_1) {
             $u_1->categories()->save(factory(\App\Models\Users\UserCategory::class)->create());
             $u_1->detail()->save($v_2 = factory(\App\Models\Users\UserDetail::class)->create());
             $v_2->avatar()->save(factory(\App\Models\Users\UserAvatar::class)->create());
             $u_1->photos()->save(factory(\App\Models\Users\UserPhoto::class)->create());
             $u_1->setting()->save(factory(\App\Models\Users\UserSetting::class)->create());
             $u_1->articles()->save($v_2 = factory(\App\Article::class)->create());
             $v_2->categories()->save(factory(\App\Models\Articles\ArticleCategory::class)->create());
             $v_2->photos()->save(factory(\App\Models\Articles\ArticlePhoto::class)->create());
             $v_2->comments()->save($w_3 = factory(\App\Models\Articles\ArticleComment::class)->create());
             //$w_3->photos()->save(factory(\App\Models\Articles\ArticleCommentPhoto::class)->create());
             $u_1->sites()->save($v_2 = factory(\App\Site::class)->create());
             $v_2->categories()->save(factory(\App\Models\Sites\SiteCategory::class)->create());
             $v_2->photos()->save(factory(\App\Models\Sites\SitePhoto::class)->create());
             $v_2->comments()->save($w_3 = factory(\App\Models\Sites\SiteComment::class)->create());
             $w_3->photos()->save(factory(\App\Models\Sites\SiteCommentPhoto::class)->create());
             $v_2->articles()->save($w_3 = factory(\App\Models\Sites\SiteArticle::class)->create());
             $w_3->photos()->save(factory(\App\Models\Sites\SiteArticlePhoto::class)->create());
             $w_3->comments()->save(factory(\App\Models\Sites\SiteArticleComment::class)->create());
             $u_1->professions()->save($v_2 = factory(\App\Profession::class)->create());
             $v_2->categories()->save($w_3 = factory(\App\Models\Professions\ProfessionCategory::class)->create());
             $v_2->comments()->save(factory(\App\Models\Professions\ProfessionPhoto::class)->create());
             $w_3->subcategories()->save(factory(\App\Models\Professions\ProfessionSubcategory::class)->create());
             $v_2->comments()->save($w_3 = factory(\App\Models\Professions\ProfessionComment::class)->create());
             //$w_3->photos()->save(factory(\App\Models\Professions\ProfessionCommentPhoto::class)->create());
         });
         factory(App\User::class, 'admin', 2)->create()->each(function ($u_1) {
             $u_1->detail()->save(factory(\App\Models\Users\UserDetail::class)->create());
         });
         echo "Done\n";
     } else {
         echo "The databases are already seeded\n\n";
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pageTitle = 'All Articles';
     $originalArticles = Article::all();
     $i = 0;
     $articles = array();
     foreach ($originalArticles as $originalArticle) {
         $author = User::find($originalArticle->author);
         $category = Category::find($originalArticle->category_id);
         $isManageable = 0;
         // administrator
         if (Auth::user()->hasRole(['administrator'])) {
             $isManageable = 1;
         }
         // department manager
         if (Auth::user()->hasRole(['department_manager'])) {
             if (Auth::user()->departments->first()->id == $author->departments->first()->id) {
                 $isManageable = 1;
             }
         }
         // category manager
         if (Auth::user()->hasRole(['category_manager'])) {
             if (Auth::user()->id == $category->manager) {
                 $isManageable = 1;
             }
         }
         // article manager
         if (Auth::user()->hasRole(['article_manager'])) {
             if (Auth::user()->id == $author->id) {
                 $isManageable = 1;
             }
         }
         $articles[$i] = array('id' => $i + 1, 'title' => $originalArticle->title, 'author' => $author->name, 'category' => $category->display_name, 'updated_at' => $originalArticle->updated_at, 'is_manageable' => $isManageable);
         $i++;
     }
     return view('home.articles.index', compact('pageTitle', 'articles'));
 }
Exemple #28
-1
 public function index()
 {
     $articles = Article::all();
     //gets the articles in assending order
     //$articles = Article::latest()->get();//order the articles in desending order
     //$articles = Article::latest('published_at')->where('published_at', '<=' Carbon::now())->get()
     //$articles = Article::latest('published_at')->published()->get();//the scope method found as scopePublished in Article class
     //return $articles;
     //return view('articles.index')->with('articles', $articles);
     return view('articles.index', compact('articles'));
 }
Exemple #29
-1
 public function supplierDetails($id)
 {
     $supp = Supplier::where('id', $id)->with('articles')->first();
     $articles_supplier = Article::where('supplier_id', $id)->get();
     if (!isset($supp->id)) {
         return redirect('/404');
     } else {
         $leftmenu['supplier'] = 'active';
         $articles = Article::all();
     }
     return view('/suppliers/details', ['supp' => $supp, 'leftmenu' => $leftmenu, 'articles' => $articles, "articles_supplier" => $articles_supplier]);
 }
Exemple #30
-2
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $pagesAll = Page::all();
     $articlesAll = Article::all();
     $templatesAll = Template::all();
     $contentAreasAll = ContentArea::all();
     $content_areas = ContentArea::lists('name', 'id');
     $pages = Page::lists('name', 'id');
     $article = Article::findOrFail($id);
     return view('site.edit', compact('article', 'pages', 'content_areas', 'pagesAll', 'articlesAll', 'templatesAll', 'contentAreasAll'));
 }