v0.0.6 Made edit and update now works dynamically

This commit is contained in:
Victor
2021-06-03 12:50:28 +02:00
parent 256f163771
commit 4024c0dd99
9 changed files with 94 additions and 30 deletions
+5 -5
View File
@@ -1,17 +1,17 @@
<?php
require "accessControl.php";
require "../../bootstrap.php";
use Backend\Model\Post;
if(isset($_GET['id'])){
$id = $_GET['id'];
if(isset($_GET['delete_id'])){
$id = $_GET['delete_id'];
$findId = Post::query()->findOrFail($id);
if(!$findId->delete()){
echo "Error could not delete record";
return "Error could not delete";
}else{
header("location: ../../Frontend/home.php?recordDeleted");
return "Record deleted";
}
}
-5
View File
@@ -7,9 +7,4 @@ use Backend\Model\Post;
if(isset($_GET['id'])){
$id = $_GET['id'];
$post = Post::query()->find($id);
if($post){
echo $post;
}
}
+3 -3
View File
@@ -8,12 +8,12 @@ if (!isset($_SESSION['token'])) {
header("location: ../../Frontend/index.php?login=notloggedin");
}
header('Content-Type: application/json;charset=UTF-8');
echo "<pre>";
$data = Post::all();
//HOme.php
$data = Post::all();
echo $data;
+3 -6
View File
@@ -5,12 +5,9 @@ require "../../bootstrap.php";
use Backend\Model\Post;
if(isset($_POST['update'])){
$id = $_POST['id'];
$title = $_POST['upTitle'];
$description = $_POST['upDescription'];
$post = Post::query()->find($id)->first();
$post->title = $title;
$post->description = $description;
$post = Post::query()->find($_POST['id']);
$post->title = $_POST['upTitle'];
$post->description = $_POST['upDescription'];
if(!$post->update()){
echo "Error could not update";