语法错误,意外'使用'(T_USE)

时间:2017-03-02 18:33:05

标签: php laravel laravel-5

我的刀片文件上有一个简短的PHP代码段

<?php


use App\ImageWork, App\User, App\Skill, App\Contact, App\ActivityLog;

$images   = ImageWork::orderBy('created_at', 'desc')->get();
$users    = User::orderBy('created_at', 'desc')->get();
$logs     = ActivityLog::orderBy('created_at', 'desc')->get();
$skills   = Skill::orderBy('created_at', 'desc')->get();
$contacts = Contact::orderBy('created_at', 'desc')->get();

?>

我明白了:

syntax error, unexpected 'use' (T_USE)

当我不添加该行时,我得到了这个

Class 'ImageWork' not found

我现在应该怎么做才是错误的?

任何提示/建议?

1 个答案:

答案 0 :(得分:2)

包含数据库外观

use Illuminate\Support\Facades\DB;

尝试使用它:

$images   = DB::table('ImageWork')->orderBy('created_at', 'desc')->get();