Actions
An action is a method that you specify in a route that needs to be executed. The required Action must be specified in the route.
In this example, in the route we specify an Show Action that will be called in the UserController controller.
$Route->Add()
->get('/users/{id}')
->controller(UserController::class)
->action('Show');
This method returns a username from the Users table where the ID is equal to the ID passed in the request.
namespace App\Controllers;
use App\Models\User;
use Src\Support\Request;
class UserController extends Controller
{
public function Index()
{
$User = new User;
$id = Request::route('id');
$User = $User->select('username')
->where('id', $id)
->start();
return response($User);
}
}