Laravel - 每次我保存时都是NotFoundHttpException

时间:2014-08-23 17:17:21

标签: laravel-4

当我在日志中保存一个条目时,我有很多错误,但它们都没有显示在浏览器中,只在storage/logs文件夹中。

这是日志:

[2014-08-23 19:12:07] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/progetti_stilogo/bootstrap/compiled.php:5687
Stack trace:
#0 /var/www/progetti_stilogo/bootstrap/compiled.php(5004): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/progetti_stilogo/bootstrap/compiled.php(4992): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/progetti_stilogo/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/progetti_stilogo/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/progetti_stilogo/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/progetti_stilogo/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/progetti_stilogo/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/progetti_stilogo/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/progetti_stilogo/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/progetti_stilogo/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/progetti_stilogo/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
[2014-08-23 19:12:07] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/progetti_stilogo/bootstrap/compiled.php:5687
Stack trace:
#0 /var/www/progetti_stilogo/bootstrap/compiled.php(5004): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/progetti_stilogo/bootstrap/compiled.php(4992): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/progetti_stilogo/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/progetti_stilogo/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/progetti_stilogo/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/progetti_stilogo/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/progetti_stilogo/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/progetti_stilogo/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/progetti_stilogo/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/progetti_stilogo/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/progetti_stilogo/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
[2014-08-23 19:12:07] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/progetti_stilogo/bootstrap/compiled.php:5687
Stack trace:
#0 /var/www/progetti_stilogo/bootstrap/compiled.php(5004): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/progetti_stilogo/bootstrap/compiled.php(4992): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/progetti_stilogo/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/progetti_stilogo/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/progetti_stilogo/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/progetti_stilogo/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/progetti_stilogo/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/progetti_stilogo/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/progetti_stilogo/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/progetti_stilogo/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/progetti_stilogo/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
[2014-08-23 19:12:20] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/progetti_stilogo/bootstrap/compiled.php:5687
Stack trace:
#0 /var/www/progetti_stilogo/bootstrap/compiled.php(5004): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/progetti_stilogo/bootstrap/compiled.php(4992): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/progetti_stilogo/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/progetti_stilogo/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/progetti_stilogo/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/progetti_stilogo/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/progetti_stilogo/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/progetti_stilogo/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/progetti_stilogo/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/progetti_stilogo/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/progetti_stilogo/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
[2014-08-23 19:12:20] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/progetti_stilogo/bootstrap/compiled.php:5687
Stack trace:
#0 /var/www/progetti_stilogo/bootstrap/compiled.php(5004): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/progetti_stilogo/bootstrap/compiled.php(4992): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/progetti_stilogo/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/progetti_stilogo/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/progetti_stilogo/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/progetti_stilogo/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/progetti_stilogo/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/progetti_stilogo/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/progetti_stilogo/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/progetti_stilogo/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/progetti_stilogo/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
[2014-08-23 19:12:20] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/progetti_stilogo/bootstrap/compiled.php:5687
Stack trace:
#0 /var/www/progetti_stilogo/bootstrap/compiled.php(5004): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/progetti_stilogo/bootstrap/compiled.php(4992): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/progetti_stilogo/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/progetti_stilogo/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/progetti_stilogo/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/progetti_stilogo/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/progetti_stilogo/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/progetti_stilogo/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/progetti_stilogo/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/progetti_stilogo/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#10 /var/www/progetti_stilogo/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []

这就是产生它的代码的和平:

public function store()
    {
        //Recupero l'input
        $input = Input::all();

        //Preparo le regole di validazione
        $rules = [
            'nome' => 'required',
            'cognome' => 'required',
            'telefono' => 'required',
            'email' => 'required|email',
            'password' => 'required|alpha_num|min:6'
        ];

        //Preparo le traduzioni degl errori
        $messages = [
            'required' => 'Il campo :attribute è obbligatorio.',
            'email' => 'Devi inserire una email valida.',
            'min' => 'Il campo :attribute deve essere lungo almeno 6 caratteri.'
        ];

        //Valido l'input
        $validation = Validator::make($input,$rules,$messages);

        //Controllo se è andato bene
        if( $validation->fails() )
        {
            //Rimando al form
            return Redirect::back()->withInput()->withErrors( $validation->messages() );
        }

        //Tutto è valido quindi posso aggiungere l'agente
        $agent = new User;
        $agent->nome = $input['nome'];
        $agent->cognome = $input['cognome'];
        $agent->email = $input['email'];
        $agent->password = Hash::make( $input['password'] );
        $agent->telefono = $input['telefono'];

        if( $input['piva_cf'] )
        {
            $agent->piva_cf = $input['piva_cf'];
        }

        //Salvo il nuovo agente
        if( $agent->save() )
        {
            //Preparo la mail da inviare con i dati di login
            $data = [
                'nome' => $input['nome'],
                'cognome' => $input['cognome'],
                'email' => $input['email'],
                'password' => $input['password']
            ];

            //Recuero il template e passo alla funzione i dati
            Mail::send('emails.agents.registration', $data, function($message) use ($data)
            {                           
                $message->to( $data['email'], $data['nome'].' '.$data['cognome'] )->subject('Benvenuto!');
            });

            return Redirect::action('admin.agents.index')->with('positive_flash_message', 'Agente inserito correttamente.');
        }

        return Redirect::action('admin.agents.index')->with('negative_flash_message', 'Agente inserito correttamente.');
    }

这是我的路线档案:

Route::get('/', 'SessionsController@create');
Route::get('login', 'SessionsController@create');
Route::get('logout', 'SessionsController@destroy');

//Quando si accede alla sezione ADMIN controllo che sia stato effettuato il login
Route::get('admin', function(){
    return View::make('admin.dashboard');
})->before('auth');

//REST per il login - Non mi servono tutti i metodi
Route::resource('sessions', 'SessionsController', ['only' => ['create','store','destroy'] ]);

//REST per gli agenti - aggiungo il prefisso admin
//Prima controllo che l'utente sia connesso e che abbia i privilegi necessari
Route::group(['prefix' => 'admin', 'before' => ['auth', 'ruolo'] ] , function(){
    Route::resource('agents', 'AgentController');
});

//REST per i clienti - aggiungo il prefisso admin
//Prima controllo che l'utente sia connesso
Route::group(['prefix' => 'admin' , 'before' => ['auth'] ] , function(){
    Route::resource('clients', 'ClientController');
});

有没有人看到这个问题?

0 个答案:

没有答案