当前位置:网站首页>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]");
});边栏推荐
- Liar report query collection network PHP source code
- 我为什么支持 BAT 拆掉「AI 研究院」
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- Scientific running robot pancakeswap clip robot latest detailed tutorial
- laravel-dompdf导出pdf,中文乱码问题解决
- Integer ==比较会自动拆箱 该变量不能赋值为空
- Programmer growth Chapter 8: do a good job of testing
- The development of speech recognition app with uni app is simple and fast.
- ELFK部署
- 运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
猜你喜欢

What are the private addresses

Attack and defense world crypto WP

那些考研后才知道的事

Self built shooting range 2022

运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化

FPGA learning notes: vivado 2019.1 add IP MicroBlaze

ELFK部署

Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?

redis6主从复制及集群

【云资源】云资源安全管理用什么软件好?为什么?
随机推荐
[cloud resources] what software is good for cloud resource security management? Why?
Multi person cooperation project to see how many lines of code each person has written
Scientific running robot pancakeswap clip robot latest detailed tutorial
Attack and defense world web WP
Redis6 data type and operation summary
MySQL get time
Godson 2nd generation burn PMON and reload system
如何把大的‘tar‘存档文件分割成特定大小的多个文件
Zhubo Huangyu: these spot gold investment skills are not really bad
Win10 - lightweight gadget
ELK 企业级日志分析系统
How to divide a large 'tar' archive file into multiple files of a specific size
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
Solution to the prompt of could not close zip file during phpword use
Network security HSRP protocol
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
PHP character capture notes 2020-09-14
Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications