Laravel 5.6助手类

时间:2018-03-04 09:44:20

标签: php laravel-5.6

Laravel 5.6,在辅助类中找不到模型名称(N:B:辅助类位于App \ Helpers \ Helper.php中)

enter image description here

3 个答案:

答案 0 :(得分:1)

模型名称不足以使Laravel检索正确的类,它也需要名称空间。

如果所有模型都在function toDo(){ SpreadsheetApp.flush(); var lock = LockService.getScriptLock(); try { lock.waitLock(5000); } catch (e) { Logger.log('Could not obtain lock after 5seconds.'); return HtmlService.createHtmlOutput("<b> Server Busy please try after some time <p>") // In case this a server side code called asynchronously you return a error code and display the appropriate message on the client side return "Error: Server busy try again later... Sorry :(" } var responses = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1"); var jobs = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Jobs"); var lastrow = responses.getLastRow(); var col = responses.getLastColumn(); var row = responses.getRange(lastrow, 1, 1, 19).getValues(); jobs.appendRow(row[0]); //copyValuesOnly(copyFromRange, copyToRangeStart); var si = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Jobs'); var range = si.getRange("A2:R"); range.sort({column: 5,ascending: true}),({column: 1, ascending:true}); Utilities.sleep(5000); lock.releaseLock)(); } 命名空间中,则可以尝试以下方法:

App\Models

但是,如果不是cas,则应将整个名称发送给您的辅助方法,如下所示:

public static function getAll($modelName)
{
    $modelName = '\App\Models\' . $modelName;
    return $modelName::all();
}

让我知道它是否对您有帮助:)

答案 1 :(得分:0)

您需要添加名称空间。

Wait.until(ExpectedConditions.presenceOfElement(By.class("article-feed-title")));

答案 2 :(得分:0)

试试这个。
首先像这样导入Model命名空间

        use Illuminate\Database\Eloquent\Model;

然后,在$ model之前添加Model关键字。像

public function getAll(Model $model){ // your code }

可能会有所帮助:)