v0.0.6 Made edit and update now works dynamically
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,4 @@ use Backend\Model\Post;
|
||||
if(isset($_GET['id'])){
|
||||
$id = $_GET['id'];
|
||||
$post = Post::query()->find($id);
|
||||
|
||||
if($post){
|
||||
echo $post;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user