post crud
This commit is contained in:
@ -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' => 'Обновлен'
|
||||
];
|
||||
}
|
||||
}
|
16
app/models/forms/CreatePostForm.php
Normal file
16
app/models/forms/CreatePostForm.php
Normal 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',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user