Answer the question
In order to leave comments, you need to log in
Phalcon, how to make the correct routing?
You need to do the right routing so that, for example, if you go to site.ru/profile/1, data with id = 1 (name, age...) is shown. If you go to site.ru/profile/1/edit, you can edit your profile, respectively, if the user is authorized and this is his profile. If you simply go to site.ru/profile, then again, if the user is authorized, he was transferred to a personal account (for example: site.ru/profile/5). How and in what way is it better to implement everything?
Answer the question
In order to leave comments, you need to log in
>> site.ru/profile/1
$router->addGet("/api/:controller/:int",
array(
"namespace" => 'ТутНаймспейсТвоегоКонтроллера', // Если не задан глобально дефолтный
"controller" => 1,
"action" => 'show',
"id" => 2
));
public function showAction($id) {
// ...
// тут выводишь данные профиля
}
$router->addGet("/api/:controller/:int/:action",
array(
"namespace" => 'ТутНаймспейсТвоегоКонтроллера', // Если не задан глобально дефолтный
"controller" => 1,
"action" => 3,
"id" => 2
));
public function editAction($id) {
// тут делай че хочешь, форму наверное нада отобразить
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question