+Static Content library, basic version
commit
664437d63a
@ -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/"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Artmark\Content\Forms;
|
||||
|
||||
use Artmark\Forms\Form;
|
||||
|
||||
use Artmark\Content\Models\Content;
|
||||
|
||||
/**
|
||||
* Description of ContentForm
|
||||
*
|
||||
* @author Andrey Pokidov <andrey.pokidov@gmail.com>
|
||||
*/
|
||||
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'));
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Artmark\Content\Migrations;
|
||||
|
||||
use Illuminate\Database\Migrations\Migration as BasicMigration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
use Artmark\Content\Models\Content;
|
||||
|
||||
/**
|
||||
* Description of Migration
|
||||
*
|
||||
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
||||
*/
|
||||
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');
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Artmark\Content\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Description of Content
|
||||
*
|
||||
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue