add postModel
This commit is contained in:
parent
c4bc65e5dc
commit
b8c98693f8
@ -4,4 +4,5 @@ namespace src;
|
||||
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
require "views/form.php";
|
||||
require "views/post.php";
|
||||
//require "views/form.php";
|
||||
|
29
post.php
Normal file
29
post.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
use src\debug\Debug;
|
||||
use src\dto\InformationDTO;
|
||||
use src\file_db_driver\FileDatabaseDriver;
|
||||
use src\models\PostModel;
|
||||
use src\Processing;
|
||||
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
ini_set("display_errors", true);
|
||||
error_reporting(-1);
|
||||
|
||||
//$fileName = "Information.txt";
|
||||
//$fileModeOpen = "a";
|
||||
|
||||
$post = new PostModel();
|
||||
$post->load($_REQUEST);
|
||||
$post->save();
|
||||
|
||||
$post1 = new PostModel();
|
||||
|
||||
$res = $post1->find(['author' => ['Stas']])->limit(10)->all();
|
||||
|
||||
$json = new Processing();
|
||||
$infArr = $json->createJsonArray($post->labels(), $res, "form2");
|
||||
|
||||
$table = new \Itguild\Tables\ListJsonTable($infArr);
|
||||
$table->create();
|
||||
$table->render();
|
4
post.txt
Normal file
4
post.txt
Normal file
@ -0,0 +1,4 @@
|
||||
autoincrement=id;last_id=2;table_name=post
|
||||
id;author;post
|
||||
1;Stas;Hello, world!!!
|
||||
2;Stas;Hello, world!!!
|
31
src/models/PostModel.php
Normal file
31
src/models/PostModel.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace src\models;
|
||||
|
||||
use src\models\BaseModel;
|
||||
|
||||
class PostModel extends BaseModel
|
||||
{
|
||||
|
||||
public int $status = 1;
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return "post.txt";
|
||||
}
|
||||
|
||||
public function fillable(): array
|
||||
{
|
||||
return [
|
||||
'author', 'post'
|
||||
];
|
||||
}
|
||||
|
||||
public function labels(): array
|
||||
{
|
||||
return [
|
||||
'author' => 'Автор',
|
||||
'post' => 'Пост'
|
||||
];
|
||||
}
|
||||
}
|
14
views/post.php
Normal file
14
views/post.php
Normal file
@ -0,0 +1,14 @@
|
||||
<form action="post.php" target="_blank" method="post">
|
||||
Автор:<br>
|
||||
<label>
|
||||
<input type = "text" name = "author" required size="50" autofocus placeholder="Автор">
|
||||
</label> <br> <br>
|
||||
|
||||
Пост:<br>
|
||||
<label>
|
||||
<textarea name = "post" rows="10" cols="50" placeholder="Текст"></textarea>
|
||||
</label> <br> <br>
|
||||
|
||||
<input type = "submit" value="Подтвердить">
|
||||
<input type="reset">
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user