我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Laravel:我应该在我的模型静态中创建自定义方法吗?

Eloquent provides almost all methods as static methods. I need to add my custom methods in model. I wonder should I declare my functions static? What's best in terms of implementation and performance?

You should use static for functions that'll logically be called statically. Read the docs for details on the difference.

Model::find() is static because you don't have an instance of the model yet.

$model->delete() is not static because it works on an existing instance of the model.

近期文章

  • Zend查询“选择一个表并使用where子句插入另一个表”?
  • 在从控制器方法返回之前,是否可以在Laravel 5中设置Cookie()?
  • 如果表单通过HTML5验证有效并将表单数据存储在本地存储中,请使用Javascript进行检查
  • 用php + Imagick获取缩略图pdf
  • Laravel查询生成器链接
  • Laravel 5 Auth更改表列
  • 从mysql修复重新获得的路径
  • PHP - udiff比较多个值
  • 购物车的图像管理
  • 如果使用函数头如何路径
  • 所有单元格都像PHP Excel一样
  • 将文本框中的输入发布到电子邮件?
  • Rest API执行时给出错误
  • 将php文件上传到我的首页WORDPRESS
  • 你管API实时流计划时区
  • 将ftp命令行cURL转换为PHP cURL
  • 偶尔引用在PHP中抛出严格错误
  • .htaccess:XAMPP中的命令'Auth_MySQL'无效
  • 如何删除codeigniter中的Duplicate where条件
  • 如何避免一次又一次显示加载时间?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华