我想问下这个service你们是咋在controller里面使用的,是直接构造注入吗
use 进去的
use 直接静态方法调用吗?
我一般用哪个业务类就use哪个的
这样也可以
protected $GrainSituationCheckResultService; public function __construct() { $this->GrainSituationCheckResultService=new GrainSituationCheckResultService(); }
感觉加个$this看起来好长 不如静态调用好看
谢谢
这样使用
我想请问一下 是不是以服务类型调用时,服务文件里面直接可以调用 父文件里面的函数的 ?
public function edit(Request $request, FileService $fileService) { $file = $request->file('file'); $fileService->upload($file); }
我这里就很粗暴: 然后:
这样IDE调用类时会有方法提示吗?
有啊
嗯,看到了有个注解声明了
protected $cartService; public function __construct(CartService $cartService) { $this->cartService = $cartService; }
凑合用
个人做法之文件结构:
个人做法之层级引用:
use 进去的
use 直接静态方法调用吗?
我一般用哪个业务类就use哪个的
这样也可以
感觉加个$this看起来好长 不如静态调用好看
谢谢
我想请问一下 是不是以服务类型调用时,服务文件里面直接可以调用 父文件里面的函数的 ?
我这里就很粗暴:


然后:
这样IDE调用类时会有方法提示吗?
有啊
嗯,看到了有个注解声明了
凑合用
个人做法之文件结构:

个人做法之层级引用:
https://www.workerman.net/doc/webman/di.html