当前位置:网站首页>Controller in laravel framework
Controller in laravel framework
2022-07-05 13:49:00 【Weichi Begonia】
1. How to create a controller
stay app/Http/Controllers Under the folder , New name is MemberController.php The file of , And add namespace , as follows :
<?php
namespace App\Http\Controllers;The new class , And define functions :( Be careful : The class name of the controller must be consistent with the file name , Class names are capitalized )
class MemberController extends Controller
{
public function info($id){
return $id."_".'member-info';
}
}2. laravel How are routes and controllers associated in
//match Method Route::match(['get', 'post'], 'member/{id}', "[email protected]")->where(['id'=>'\d+']);
such as , I want to set up a route , And above MemberController.php In the document info Function correlation , It can be defined as follows :
// Pass in the parameter
Route::get('member/{id}', "[email protected]")->where(['id'=>'\d+']);where Function can set some restrictions on parameters
3. After controller Association , How to use the routing feature ?- How to use any/match/group/ Route alias and other methods ?
//any Method
Route::any('member/{id}', "[email protected]")->where(['id'=>'\d+']);//match Method
Route::match(['get', 'post'], 'member/{id}', "[email protected]")->where(['id'=>'\d+']);// Routing alias , Note the direction controller when key by uses
Route::get('member/info/{id}', ["as"=>"member", "uses"=>"[email protected]"]);// routing group
Route::group(["prefix"=>"member"], function(){
Route::get('info/{id}', "[email protected]");
});边栏推荐
- Catch all asynchronous artifact completable future
- Elk enterprise log analysis system
- 运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
- Don't know these four caching modes, dare you say you understand caching?
- Zhubo Huangyu: it's really bad not to understand these gold frying skills
- stm32逆向入门
- Wechat app payment callback processing method PHP logging method, notes. 2020/5/26
- Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
- Intranet penetration tool NetApp
- Simple PHP paging implementation
猜你喜欢

About the problem and solution of 403 error in wampserver

stm32逆向入门

记录一下在深度学习-一些bug处理

STM32 reverse entry

Kotlin协程利用CoroutineContext实现网络请求失败后重试逻辑

龙芯派2代烧写PMON和重装系统

MMSeg——Mutli-view时序数据检查与可视化

Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!

搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2

Liar report query collection network PHP source code
随机推荐
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
Source code analysis of etcd database -- peer RT of inter cluster network layer client
Aspx simple user login
Primary code audit [no dolls (modification)] assessment
asp. Net read TXT file
Programmer growth Chapter 8: do a good job of testing
Convolutional Neural Networks简述
Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
Redis6 data type and operation summary
Huawei push service content, read notes
redis6数据类型及操作总结
深拷贝真难
研究生可以不用学英语?只要考研英语或六级分数高!
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
PHP generate Poster
ZABBIX monitoring
[MySQL usage Script] catch all MySQL time and date types and related operation functions (3)
leetcode 10. Regular expression matching regular expression matching (difficult)
南理工在线交流群
Ordering system based on wechat applet