2021-06-02 07:01:51 +00:00
|
|
|
<?php
|
|
|
|
//require our bootstrap file for database connection
|
|
|
|
require "../../bootstrap.php";
|
|
|
|
|
|
|
|
use Backend\Model\Post;
|
|
|
|
|
2021-06-07 13:01:28 +00:00
|
|
|
if(isset($_POST['title'])){
|
|
|
|
//Create a new initialize
|
|
|
|
$post = new Post();
|
2021-06-02 07:01:51 +00:00
|
|
|
|
2021-06-07 13:01:28 +00:00
|
|
|
//Get the data from post and save it to the post model
|
|
|
|
$post->title = $_POST['title'];
|
|
|
|
$post->description = $_POST['description'];
|
2021-06-02 07:01:51 +00:00
|
|
|
|
2021-06-07 13:01:28 +00:00
|
|
|
//Call the save function.
|
2021-06-08 12:08:24 +00:00
|
|
|
if($post->save())
|
|
|
|
echo json_encode(array($post->id, $post->created_at));
|
2021-06-02 07:01:51 +00:00
|
|
|
}
|