<?php
//routes/admin/post.php
$f3->route('POST /admin/post', function($f3){
    require('controllers/posts/insert.php');
    insert($f3);
});

$f3->route('GET /admin/post/edit/@id', function($f3){
    require('controllers/posts/selectOne.php');
    selectOne($f3, $f3->get('PARAMS.id'));
});

$f3->route('POST /admin/post/edit/@id', function($f3){
    require('controllers/posts/update.php');
    update($f3, $f3->get('PARAMS.id'));
});

$f3->route('GET /admin/post/delete/@id', function($f3){
    require('controllers/posts/delete.php');
    delete($f3, $f3->get('PARAMS.id'));
});

 

<?php
//controllers/posts/delete.php
function delete($f3, $id){
    $collection = $f3->get('DB')->posts;
    $collection->deleteOne(['id'=>$id]);

    $f3->reroute('/admin');
}

 

GitHub: https://github.com/Sokhavuth/multimedia_

Heroku: https://khmerweb-multimedia1.herokuapp.com/