0
我已經在App \ Http \ Helpers目錄下創建了一個自定義幫助器類,並且正在使用刀片@inject()
注入該類,如下所示:刀片@inject()不能在Laravel 5.2上爲自定義幫助器類型工作
@inject('Hello', 'App\Http\Helpers\Helper')
而且,我在同一視圖中引用Hello
類似如下:
Hello::activity(1, 2, 3)
然而,這將返回以下錯誤:
Fatal error: Class 'Hello' not found (View: /Users/sumon/Desktop/TimeCop/resources/views/diary/view.blade.php)
有什麼我失蹤?
下面是完整的類Helper類我創建:
<?php
namespace app\Http\Helpers;
class Helper
{
public static function activity($keyboard, $clicks, $drags)
{
if (($keyboard + $clicks + $drags)/3 >= 100) {
return 100;
} elseif (($keyboard + $clicks + $drags)/3 >= 90) {
return 90;
} elseif (($keyboard + $clicks + $drags)/3 >= 80) {
return 80;
} elseif (($keyboard + $clicks + $drags)/3 >= 70) {
return 70;
} elseif (($keyboard + $clicks + $drags)/3 >= 60) {
return 60;
} elseif (($keyboard + $clicks + $drags)/3 >= 50) {
return 50;
} elseif (($keyboard + $clicks + $drags)/3 >= 40) {
return 40;
} elseif (($keyboard + $clicks + $drags)/3 >= 30) {
return 30;
} elseif (($keyboard + $clicks + $drags)/3 >= 20) {
return 20;
} elseif (($keyboard + $clicks + $drags)/3 >= 10) {
return 10;
}
return 0;
}
}
AAH人後運行
composer dump
,我錯過了。但是,我不需要在類加載正常時轉儲作曲者。 –