/** * Update request rules. * * @param array $rules * * @return array */ private function updateRules(array $rules) { $rules['category'] .= '|in:' . implode(',', array_keys(Category::getSelectOptions(false))); $rules['tags'] .= '|in:' . implode(',', array_keys(Tag::getSelectOptions())); $rules['status'] .= '|in:' . implode(',', PostStatus::keys()); return $rules; }
/** * {@inheritdoc} */ public function up() { $this->createSchema(function (Blueprint $table) { $table->increments('id'); $table->integer('author_id')->unsigned()->default(0); $table->integer('category_id')->unsigned(); $table->string('title'); $table->string('slug'); $table->text('excerpt'); $table->longtext('content'); $table->enum('status', PostStatus::keys()); $table->dateTime('publish_date'); $table->timestamps(); $table->softDeletes(); $table->unique('slug'); }); }
/** * Edit a post. * * @param \Arcanesoft\Blog\Models\Post $post * * @return \Illuminate\View\View */ public function edit(Post $post) { $this->authorize('blog.posts.update'); $title = 'Blog - Posts'; $this->setTitle($title); $this->addBreadcrumb('Edit post'); $categories = Category::getSelectOptions(); $tags = Tag::getSelectOptions(); $statuses = PostStatus::all(); return $this->view('foundation.posts.edit', compact('post', 'categories', 'tags', 'statuses')); }
/** * Get the status name attribute. * * @return null|string */ public function getStatusNameAttribute() { return PostStatus::get($this->status); }