andrewelkins / Laravel-4-Bootstrap-Starter-Site

Laravel 4 Starter Site is a basic blog application using several nice community packages.
1.77k stars 602 forks source link

Unable to create new controller #239

Closed asivaneswaran closed 11 years ago

asivaneswaran commented 11 years ago

Hey guys,

I tried creating a new controller.

Here is the controller ( just the top ):

<?php

class AdminRestaurantsController extends AdminController {

/**
 * Restaurant Model
 * @var Restaurant
 */
protected $restaurant;

public function __construct(Restaurant restaurant)
{
    parent::__construct();
    $this->restaurant = $restaurant;
}

/**
 * Display a listing of the resource.
 *
 * @return Response
 */
public function getIndex()
{
    // Title
    $title = Lang::get('admin/restaurants/title.restaurants_management');

    // Grab all the restaurants
    $restaurants = $this->restaurant;

    // Show the page
    return View::make('admin/restaurants/index', compact('restaurants', 'title'));
}

and here is the routes:

  # Restaurant Management
Route::get('restaurants/{restaurant}/show', 'AdminRestaurantsController@getShow')
    ->where('restaurant', '[0-9]+');
Route::get('restaurants/{restaurant}/edit', 'AdminRestaurantsController@getEdit')
    ->where('restaurant', '[0-9]+');
Route::post('restaurants/{restaurant}/edit', 'AdminRestaurantsController@postEdit')
    ->where('restaurant', '[0-9]+');
Route::get('restaurants/{restaurant}/delete', 'AdminRestaurantsController@getDelete')
    ->where('restaurant', '[0-9]+');
Route::post('restaurants/{restaurant}/delete', 'AdminRestaurantsController@postDelete')
    ->where('restaurant', '[0-9]+');
Route::controller('restaurants', 'AdminRestaurantsController');

But I keep getting: Class AdminRestaurantsController does not exist

  1. ReflectionException …\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Inspector.php29
  2. ReflectionClass __construct …\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Inspector.php29
  3. Illuminate\Routing\Controllers\Inspector getRoutable …\vendor\laravel\framework\src\Illuminate\Routing\Router.php247
  4. Illuminate\Routing\Router controller …\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php209
  5. Illuminate\Support\Facades\Facade __callStatic …\app\routes.php44
  6. Illuminate\Support\Facades\Route controller …\app\routes.php44
  7. {closure} <#unknown>0
  8. call_user_func …\vendor\laravel\framework\src\Illuminate\Routing\Router.php650
  9. Illuminate\Routing\Router group …\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php209
  10. Illuminate\Support\Facades\Facade __callStatic …\app\routes.php72
  11. Illuminate\Support\Facades\Route group …\app\routes.php72
  12. require …\vendor\laravel\framework\src\Illuminate\Foundation\start.php253
  13. require …\bootstrap\start.php61
  14. require_once …\public\index.php35

Thanks, Ara

adrianricardo commented 10 years ago

How were you able to solve this? I'm having the same issue

andrew13 commented 10 years ago

You'll need to run

composer dump-autoload
adrianricardo commented 10 years ago

thanks!