slider CRUD
This commit is contained in:
42
kernel/modules/slider/models/Slider.php
Normal file
42
kernel/modules/slider/models/Slider.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\slider\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string $additional_information
|
||||
* @property string $content
|
||||
* @property string $link
|
||||
*/
|
||||
|
||||
class Slider extends Model
|
||||
{
|
||||
const int DISABLE_STATUS = 0;
|
||||
const int ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = "slider";
|
||||
protected $fillable = ['title', 'additional_information', 'content', 'link'];
|
||||
|
||||
public static function labels()
|
||||
{
|
||||
return [
|
||||
'title' => 'Заголовок',
|
||||
'content' => 'Контент',
|
||||
'link' => 'Ссылка',
|
||||
'additional_information' => 'Дополнительная информация',
|
||||
'status' => 'Статус'
|
||||
];
|
||||
}
|
||||
|
||||
public static function getStatus(): array
|
||||
{
|
||||
return [
|
||||
self::DISABLE_STATUS => "Не активный",
|
||||
self::ACTIVE_STATUS => "Активный",
|
||||
];
|
||||
}
|
||||
|
||||
}
|
19
kernel/modules/slider/models/forms/CreateSliderForm.php
Normal file
19
kernel/modules/slider/models/forms/CreateSliderForm.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\slider\models\forms;
|
||||
|
||||
use kernel\FormModel;
|
||||
|
||||
class CreateSliderForm extends FormModel
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|min-str-len:5',
|
||||
'additional_information' => 'nullable',
|
||||
'content' => 'required|min-str-len:10',
|
||||
'link' => '',
|
||||
'status' => 'required|integer',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user