Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
declare(strict_types=1);
namespace Source\Domains\General;
use Devitools\Persistence\AbstractModel;
/**
* Class Category
*
* @package Source\Domains\General
*/
class Category extends AbstractModel
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'categories';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'description',
'active',
];
/**
* @var array
*/
protected $rules = [
'name' => ['required'],
];
/**
* @var array
*/
protected $casts = [
'active' => 'boolean',
];
/**
* @return string
*/
public function domain(): string
{
return 'general.category';
}
}
<?php
declare(strict_types=1);
namespace Source\Domains\General;
use Devitools\Agnostic\Schema;
/**
* Class Category
*
* @package Source\Domains\General
*/
class CategorySchema extends Schema
{
/**
* The table associated with the model.
*
* @var string
*/
protected function source(): string
{
return 'categories';
}
/**
* @return string
*/
public static function domain(): string
{
return 'general.category';
}
/**
* @return Schema
*/
protected function construct(): Schema
{
$this->addField('name')
->fieldIsString()
->validationRequired();
$this->addField('description')
->fieldIsString();
$this->addField('active')
->fieldIsBoolean();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.