当前位置:网站首页>Laravel - model (new model and use model)
Laravel - model (new model and use model)
2022-07-05 13:54:00 【Weichi Begonia】
stay app New file in directory member.php As a model file :
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Member extends Model{
public static function getMember(){
return 'member name is tom';
}
}stay controller At the time of invocation , because member.php Medium getMember Is a static method , It can be used directly Class name :: Function name To make a call :
<?php
namespace App\Http\Controllers;
use App\Member;
use Illuminate\Http\Request;
class MemberController extends Controller
{
public function info(Request $request, $id){
return Member::getMember(); // How to call static functions
}
}
边栏推荐
- Scientific running robot pancakeswap clip robot latest detailed tutorial
- 2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试
- leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
- web3.eth. Filter related
- Elfk deployment
- 网络安全-HSRP协议
- asp.net 读取txt文件
- LeetCode_67(二进制求和)
- Embedded software architecture design - message interaction
- NFT value and white paper acquisition
猜你喜欢

redis6事务和锁机制

Nantong online communication group

那些考研后才知道的事

牛客网:拦截导弹

Why do I support bat to dismantle "AI research institute"
Jetpack Compose入门到精通
![[South China University of technology] information sharing of postgraduate entrance examination and re examination](/img/a8/41e62a7a8d0a2e901e06c751c30291.jpg)
[South China University of technology] information sharing of postgraduate entrance examination and re examination

Liar report query collection network PHP source code

Catch all asynchronous artifact completable future

RK3566添加LED
随机推荐
2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试
PHP character capture notes 2020-09-14
Xampp configuring multiple items
Scientific running robot pancakeswap clip robot latest detailed tutorial
研究生可以不用学英语?只要考研英语或六级分数高!
Log4j utilization correlation
Catch all asynchronous artifact completable future
Solve the problem of "unable to open source file" xx.h "in the custom header file on vs from the source
【云资源】云资源安全管理用什么软件好?为什么?
In addition to the root directory, other routes of laravel + xampp are 404 solutions
jasypt配置文件加密|快速入门|实战
蓝桥杯学习2022.7.5(上午)
Liar report query collection network PHP source code
Redis6 master-slave replication and clustering
几款分布式数据库的对比
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
[js] basic syntax - for loop
我为什么支持 BAT 拆掉「AI 研究院」
With 4 years of working experience, you can't tell five ways of communication between multithreads. Dare you believe it?
asp. Net read TXT file