-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoutes.php
More file actions
62 lines (53 loc) · 2.05 KB
/
Routes.php
File metadata and controls
62 lines (53 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) 2021 CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
/**
* --------------------------------------------------------------------
* General Routing
* --------------------------------------------------------------------
*/
$routes->get('/', 'Home::index');
// Sessions
$routes->get('session', 'SessionStorage::index');
$routes->get('session/flash', 'SessionStorage::flashData');
// Helpers
$routes->get('helper', 'Helper::index');
// File Upload
$routes->get('upload', 'FileUpload::index');
$routes->post('upload', 'FileUpload::upload');
// Blog Restful API
$routes->resource('blogs', ['controller' => 'BlogAPI']);
/**
* --------------------------------------------------------------------
* Group Routing
* --------------------------------------------------------------------
*/
$routes->group(
'blogs',
['namespace' => 'App\Controllers'],
static function ($routes) {
$routes->get('/', 'Blogs::index'); // Static route for listing all blogs
$routes->get('create', 'Blogs::create'); // Route for creating a new blog
$routes->post('store', 'Blogs::store'); // Route for storing a new blog
$routes->get('(:num)', 'Blogs::show/$1'); // Dynamic route for showing a single blog by ID
$routes->get('edit/(:num)', 'Blogs::edit/$1'); // Dynamic route for editing a blog by ID
$routes->post('update/(:num)', 'Blogs::update/$1'); // Dynamic route for updating a blog by ID
$routes->get('delete/(:num)', 'Blogs::delete/$1'); // Dynamic route for deleting a blog by ID
}
);
/**
* --------------------------------------------------------------------
* Filter Routing
* --------------------------------------------------------------------
*/
$routes->group('admin', ['filter' => 'auth'], static function ($routes) {
$routes->get('/', 'Admin::index');
// Add more routes that need login
});