当前位置:网站首页>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]");
});边栏推荐
- Attack and defense world web WP
- restTemplate详解
- Wonderful express | Tencent cloud database June issue
- 49. Grouping of alphabetic ectopic words: give you a string array, please combine the alphabetic ectopic words together. You can return a list of results in any order. An alphabetic ectopic word is a
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
- Flutter 3.0更新后如何应用到小程序开发中
- RK3566添加LED
- Programmer growth Chapter 8: do a good job of testing
- Multi person cooperation project to see how many lines of code each person has written
- :: ffff:192.168.31.101 what address is it?
猜你喜欢

锚点导航小demo
Jetpack compose introduction to mastery

南理工在线交流群

Attack and defense world web WP

Solve the problem of invalid uni app configuration page and tabbar

Laravel framework operation error: no application encryption key has been specified

Redis6 master-slave replication and clustering

Mmseg - Mutli view time series data inspection and visualization

Idea remote debugging agent

jasypt配置文件加密|快速入门|实战
随机推荐
:: ffff:192.168.31.101 what address is it?
Jetpack Compose入门到精通
Apicloud studio3 WiFi real machine synchronization and WiFi real machine preview instructions
NFT value and white paper acquisition
面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?
不知道这4种缓存模式,敢说懂缓存吗?
Record in-depth learning - some bug handling
::ffff:192.168.31.101 是一个什么地址?
Basic characteristics and isolation level of transactions
如何把大的‘tar‘存档文件分割成特定大小的多个文件
Resttemplate details
Rk3566 add LED
Wonderful express | Tencent cloud database June issue
About the problem and solution of 403 error in wampserver
Integer ==比较会自动拆箱 该变量不能赋值为空
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
Nantong online communication group
Summit review | baowanda - an integrated data security protection system driven by compliance and security
Redis6 master-slave replication and clustering
aspx 简单的用户登录