Home > Enterprise >  laravel unexpected 'all' from controller
laravel unexpected 'all' from controller

Time:06-09

I have a code below

<?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'));
      }
}

For some reason all is not recognied, I get - syntax error, unexpected 'all'

CodePudding user response:

You want $sh = Shop::all(). You don't instantiate it the Shop class yourself here.

  • Related