commit 664437d63a8461165dfa0888bd61573abccf1105 Author: Andrey Pokidov Date: Mon Mar 30 14:08:41 2020 +0700 +Static Content library, basic version diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..bfbe81d --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "artmark/laravel-content", + "description": "A library of common functionality of Laravel content", + "type": "library", + "license": "Proprietary", + "authors": [ + { + "name": "Andrey Pokidov", + "email": "pokidov@e-traffic.ru" + } + ], + "require": {}, + "autoload": { + "psr-0": { + "Artmark\\Content\\": "src/" + } + } +} diff --git a/src/Forms/ContentForm.php b/src/Forms/ContentForm.php new file mode 100644 index 0000000..5e2e85d --- /dev/null +++ b/src/Forms/ContentForm.php @@ -0,0 +1,32 @@ + + */ +class ContentForm extends Form +{ + public function addContentFields() + { + $this->newText('title')->setId('title') + ->setLabelText(__('admin/content.title_field')) + ->setMaxLength(Content::MAXIMAL_TITLE_LENGTH) + ->setRequired(); + + $this->newTextArea('keywords')->setId('keywords') + ->setLabelText(__('admin/content.keywords_field')); + + $this->newTextArea('description')->setId('description') + ->setLabelText(__('admin/content.description_field')); + + $this->newTextArea('body')->setId('body') + ->setLabelText(__('admin/content.body_field')); + } +} diff --git a/src/Migrations/Migration.php b/src/Migrations/Migration.php new file mode 100644 index 0000000..8444417 --- /dev/null +++ b/src/Migrations/Migration.php @@ -0,0 +1,27 @@ + + */ +abstract class Migration extends BasicMigration +{ + const MAXIMAL_TITLE_SIZE = 1024; + + public function addContentFields(Blueprint $table) + { + $table->tinyInteger('status')->default(Content::STATUS_DRAFT); + $table->string('title', self::MAXIMAL_TITLE_SIZE); + $table->text('keywords'); + $table->text('description'); + $table->mediumText('body'); + } +} diff --git a/src/Models/Content.php b/src/Models/Content.php new file mode 100644 index 0000000..84022a4 --- /dev/null +++ b/src/Models/Content.php @@ -0,0 +1,32 @@ + + */ +class Content extends Model +{ + const MAXIMAL_TITLE_LENGTH = 1024; + + const STATUS_DRAFT = 0x0; + const STATUS_PUBLISHED = 0x1; + + protected $fillable = [ + 'title', 'keywords', 'description', 'body' + ]; + + public function isDraft() + { + return $this->status == self::STATUS_DRAFT; + } + + public function isPublished() + { + return $this->status == self::STATUS_PUBLISHED; + } +}