pingpong-labs / modules

Laravel 5 Modules
https://pingpong-labs.github.io/docs/modules.html
BSD 3-Clause "New" or "Revised" License
576 stars 151 forks source link

Cannot use resource route #261

Open danim80 opened 8 years ago

danim80 commented 8 years ago

When I try to access the 'client/1/edit' it throws NotFoundHttpException.

The route:list shows the following routes

GET|HEAD | client/create | client..create | Modules\Client\Http\Controllers\ClientController@create GET|HEAD | client/{} | client..show | Modules\Client\Http\Controllers\ClientController@show PUT|PATCH | client/{} | client..update | Modules\Client\Http\Controllers\ClientController@update DELETE | client/{} | client..destroy | Modules\Client\Http\Controllers\ClientController@destroy GET|HEAD | client/{}/edit | client..edit | Modules\Client\Http\Controllers\ClientController@edit

The route is: Route::group(['middleware' => 'web', 'prefix' => 'client', 'namespace' => 'Modules\Client\Http\Controllers'], function() { Route::resource('/', 'ClientController'); });

ghost commented 8 years ago

Please paste content of your Modules\Client\Http\routes.php file.

danim80 commented 8 years ago

Route::group(['middleware' => 'web', 'prefix' => 'client', 'namespace' => 'Modules\Client\Http\Controllers'], function() { Route::resource('/', 'ClientController'); });

ghost commented 8 years ago

In default, ClientController doesn't have resource-like methods (store, edit, update etc.) - only index(). Do you created it in your controller file?

danim80 commented 8 years ago

<?php namespace Modules\Client\Http\Controllers;

use Pingpong\Modules\Routing\Controller; use Modules\Client\Entities\Clients;

class ClientController extends Controller {

public function index()
{
    return view('client::index', ['clients'=>Clients::get()]);
}
public function create()
{
    return view('client::create');
}
public function edit($id)
{
    return view('client::edit');
}

}

ghost commented 8 years ago

I'm checked it in my installation of laravel + modules. Works the same, but I'm found a workaround:

define your route as (i.e.): Route::resource('/res', 'ClientController').

It generates: client/{res} client/{res}/edit etc.

danim80 commented 8 years ago

Route::resource('/id', 'ClientController'); now generates

client/id client/id client/id/create client/id/{id} client/id/{id} client/id/{id} client/id/{id}/edit

danim80 commented 8 years ago

Other solutions?

danim80 commented 8 years ago

Nobody has this problem?