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:']); }
/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function search() { $this->article = Article::published(); $articleCommentCounts = $this->_getArticleCommentsNumber(); $articles = $this->article; $categories = ArticleCategory::all()->sortBy('name'); return view('articles.search', compact('articles', 'categories', 'articleCommentCounts')); }