post crud

This commit is contained in:
2024-07-25 16:15:18 +03:00
parent 653bf674c9
commit 25e585655c
16 changed files with 303 additions and 46 deletions

View File

@ -2,8 +2,26 @@
namespace app\models;
use \Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $post
* @property string $username
* @method static where(int[] $array)
* @method static find($id)
*/
class Post extends Model
{
protected $table = 'post';
protected $fillable = ['post', 'user_id'];
protected $fillable = ['post', 'username'];
public static function labels(): array
{
return [
'post' => 'Пост',
'username' => 'Пользователь',
'created_at' => 'Создан',
'updated_at' => 'Обновлен'
];
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace app\models\forms;
use kernel\FormModel;
class CreatePostForm extends FormModel
{
public function rules(): array
{
return [
'post' => 'required|min-str-len:1|max-str-len:2048',
'username' => 'required|min-str-len:1|max-str-len:50',
];
}
}