vendredi 30 juin 2017

Registering Controller in Service Provider in Laravel

I am getting the following error when I visit my localhost website http:\guam.dev\people

ReflectionException

Class Dashboard does not exist

This is my Directory structure.

laravel
-vendor
--student
---people
----composer.json
----src
-----PeopleServiceProvider.php
-----Controllers
------SuperAdmin
-------Dashboard.php
-----Routes
-----Views

This is my PeopleServiceProvider.php

namespace Student\People;

use Illuminate\Support\ServiceProvider;

class PeopleServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        include __DIR__ . '/Routes/routes.php';
        $this->loadViewsFrom(__DIR__.'/Views/SuperAdmin/Dashboard', 'People');
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->make('Student\People\Dashboard');
    }
}

Controller file : Dashboard.php

namespace Student\People;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class Dashboard extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('app');
    }
}

What am I doing wrong ? I am following an old tutorial, but there isn't much explanation about controllers there.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire