Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Laravel 5 Framework getting started Learning tutorial

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "Laravel 5 Framework introduction Learning course". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Permission verification

The background address is http://localhost:88/admin, and all our background operations will be carried out under this page or its sub-pages. With the Auth provided by Laravel 5, we only need to change a small part of the routing code to achieve permission verification.

First, change the code of the routing group to:

The copy code is as follows:

Route::group (['prefix' = >' admin', 'namespace' = >' Admin', 'middleware' = >' auth'], function ()

{

Route::get ('/', 'AdminHomeComtroller@index')

Route::resource ('pages',' PagesController')

});

There is only one change in the above code: an entry `'middleware' = > 'auth' `is added to the first parameter (an array) of `auth' ()`. Visit http://localhost:88/admin now and you should jump to the login page. If there is no jump, do not panic, exit from the upper right corner and re-enter.

Our personal blog system does not want people to register casually. Next, we will change some of the routing code to retain only the basic login and logout functions.

Delete:

The copy code is as follows:

Route::controllers ([

'auth' = > 'Auth\ AuthController'

'password' = > 'Auth\ PasswordController'

])

Add:

The copy code is as follows:

Route::get ('auth/login',' Auth\ AuthController@getLogin')

Route::post ('auth/login',' Auth\ AuthController@postLogin')

Route::get ('auth/logout',' Auth\ AuthController@getLogout')

The background with minimal permission verification has been completed, and this background currently manages only the resource Page (pages). Next we will build the foreground page to show the Pages.

two。 Build the home page

First sort out the routing code and change the top two lines of the route:

The copy code is as follows:

Route::get ('/', 'WelcomeController@index')

Route::get ('home',' HomeController@index')

Change it to:

The copy code is as follows:

Route::get ('/', 'HomeController@index')

We will directly use HomeController to support our foreground page presentation.

You can delete the learnlaravel5/app/Http/Controllers/WelcomeController.php controller file and the learnlaravel5/resources/views/welcome.blade.php view file at this point.

Modify the learnlaravel5/app/Http/Controllers/HomeController.php to:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report