Ok, the full routes.php
file that I use... I just pasted it here: http://pastebin.com/kaCP3NwK
//The route group for all other requests needs to validate admin, model, and add assets
Route::group(array('before' => 'validate_admin|validate_model'), function()
{
//Model Index
Route::get('admin/(:any)', array(
'as' => 'admin_index',
'uses' => 'admin@index'
));
administrator config:
...
'models' => array(
'news' => array(
'title' => 'News',
'single' => 'news',
'model' => 'AdminModels\\News',
),
...
links generator:
@foreach (Config::get('administrator.models') as $key => $model)
@if (Admin\Libraries\ModelHelper::checkPermission($key))
<?php $key = is_numeric($key) ? $model : $key; ?>
<li>
{{ HTML::link(URL::to_route('admin_index', array($key)), $model['title']) }}
</li>
@endif
@endforeach
public function action_index($modelName)
{
//first we get the data model
$model = ModelHelper::getModelInstance($modelName);
$view = View::make("admin.index",
array(
"modelName" => $modelName,
)
);
//set the layout content and title
$this->layout->modelName = $modelName;
$this->layout->content = $view;
}
So, when accessing http://example.com/admin/news
the news
is sent to action_index
... but for some reason it doesn't get there and it returns 404
This error usually means that Laravel was not able to find the controller, controller method or a 404 error was thrown by your custom code. Some common steps to debug these would be to confirm that the route, controller, and method exist. If they all exist, then check to see if your code is throwing a 404 error.
Here are some ways you can try to resolve a 404 error: Double-check the URL you've entered, especially if you typed it by hand. Refresh the webpage. Use Google (or a similar search engine) to try and find the page again.
You need to create blade views for error pages, move to this path resources/views/ inside here create errors folder and within the directory create 404. blade. php file. It will redirect you to the 404 page if you don't find the associated URL.
One of the often-used queries is Laravel Debug. It is an application, which is a part of the Laravel Framework, that helps the developer to keep a tab on the errors and bugs that may appear during the development phase. It is a handy tool since it points out the errors while the application is being developed.
Notice that I defined the following 'model' => 'AdminModels\\News',
when actually my namespace
register was Admin\Models
, so setting it to 'model' => 'Admin\Models\\News',
for my issue for the 404
Routes are evaluated in the order that they're registered, so the (:any) route should be last. You're being sent (I think) to admin@index -- if that function isn't defined yet, that's why you're getting a 404.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With