Laravel Classroom image

Prashant  Nigam / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9|Last
Lessons:-Using Controllers

Using Controllers 9
1 /application/controllers/account.php
Before we can use our Controller we will need to register it in /application/routes.php. Let’s
add the following line :
1 <?php
2
3 // application/routes.php
4 Route::controller('account');
If our controller is in a sub-directory of the controllers directory simply use periods (.) to
separate the directories like so :
1 <?php
2
3 // application/routes.php
4 Route::controller('in.a.sub.directory.account');
If our controller exists in a bundle, simply prefix with the bundle name and a double colon :
1 <?php
2
3 // application/routes.php
4 Route::controller('mybundle::account');
Now if we visit:
1 http://myproject/account/login
we see This is the login form.. This is because now that our Controller has been mapped in
the Route class, the first segment (between the slashes) of the URL specifies the controller, and
the second segment (yes, again between the slashes) specifies the action.
In simple terms /account/login is mapped to Account_Controller->action_login() and the
result of our method is displayed.
Now let’s try visiting /account instead :
1 This is the profile page.
Why does this happen? The index action is a special action which is called when no action is
specified in the URI, therefore the above page could also be “called” with the following URI :
1 /account/index

 
 
 

Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)