Created
June 27, 2020 18:57
-
-
Save wilcorrea/b1663acc85b16590453ecc9b803a0e78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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