我在下面有一個代碼
<?php
namespace App\Http\Controllers\administrator;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\shop;
class DashboardController extends Controller
{
public function __construct() {
$this->middleware('auth');
}
public function index() {
$sh = new shop::all();
return view('admin.dashboard', compact('sh'));
}
}
由于某種原因,所有內容都無法識別,我得到 - 語法錯誤,意外的“全部”
uj5u.com熱心網友回復:
你想要$sh = Shop::all()。您不會在這里自己將其實體化為 Shop 類。
uj5u.com熱心網友回復:
不要實體化類,使用靜態方法:
Shop::all()
請參閱https://laravel.com/docs/9.x/eloquent#retrieving-models中的 Laravel 檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/487865.html
標籤:拉拉维尔
