0 down vote favorite
I am new to the Laravel framework and I am stuck with routing.
Folder structure:
app
controllers\
admin\ authcontroller.php
Routes:
Route::get('admin/logout', array('as' =>'admin.logout', 'uses'=>'App\Controllers\Admin\AuthController@getLogout' ));
Route::get('admin/login', array('as' =>'admin.login' , 'uses'=>'App\Controllers\Admin\AuthController@getLogin' ));
Route::get('admin/login',array('as'=>'admin.login.post','uses'=>'App\Controllers\Admin\AuthController@postLogin'));
Route::group( array('prefix' =>'admin' ,'before'=>'auth.admin' ),function (){
Route::any('/','App\Controllers\Admin\PagesController@index');
Route::resource('articles','APP\Controllers\Admin\ArticlesController');
Route::resource('pages','App\Controllers\Admin\PagesController');
});
authcontroller.php
<?php
namespace App\Controllers\Admin
use Auth, BaseController, Form, Input, Redirect, Sentry, View;
class Authcontroller extends BaseController
{
public function getLogin(){
die('here');
return View::make('admin.auth.login');
}
public function postLogin(){
$credentials= array(
'email' =>Input::get('email') ,
'password'=>Input::get('password'),
);
try{
$user=Sentry::authenticate($credentials,FALSE);
if($user){
return Redirect::route('admin.pages.index');
}
}
catch (Exception $e){
return Redirect::route('admin.login')->withErrors(array('login' => $e->getMessage() ));
}
}
/*
logout function
*/
public function getLogout(){
Sentry::logout();
return Redirect::route('admin.login');
}
}
Error Class App\Controllers\Admin\AuthController does not exist
*** what is make that error appear
also when i run composer dump-autoload from the CMD i did not found the namespace loaded in autoload_namespaces.php file ***
Change your routes to use "Admin\AuthController@getLogin"
and class Authcontroller to AuthController
make sure you dump-autoload
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community