I am not using Eloquent ORM
for Laravel 4 and willing to bind my Model with Edit Form using model binding
. My code is given below:
Routes.php
Route::get('/', 'HomeController@index');
Route::get('exchanges', 'Exchange@index');
//Route::get('details/{exchangeID}', 'Exchange@details');
//add question to make the parameter option
Route::get('details/{exchangeID?}', function($exchangeID = 0)
{
return App::make('Exchange')->details($exchangeID);
});
//Admin Dashboard
Route::get('admin', 'Exchange@dashboard');
//Route::get('admin/exchange/edit/{exchangeID?}', function($exchangeID = 0)
//{
// return App::make('Exchange')->edit($exchangeID);
//});
Route::model('exchange', 'ExchangeModel');
Route::get('admin/exchange/edit/{exchange}', array('uses' => 'Exchange@edit', 'as' => 'exchange.edit'));
Controller Method
public function edit(ExchangeModel $exchange)
{
return View::make('exchangeedit')->with('exchange', $exchange);
VIew
{{ Form::model($exchange, array('route' => array('exchange.edit', $exchange->id))) }}
{{ Form::close() }}
Model
public static function all()
{
return DB::select('select * from Exchanges');
}
However When I visit: http://localhost/path/site/public/admin/exchange/edit/4
It considers it a 404 and redirects to a 404 page. Where am I going wrong?