2016-06-02 23 views
0

私は解決策を探しましたが運はありませんでした。Laravel 5 - コントローラのアクションをリダイレクトできません

エラーメッセージ:

InvalidArgumentException in UrlGenerator.php line 602: 
Action [email protected] not defined. 

route.php:

Route::group(['prefix' => 'user'], function() { 

     Route::get('/{id}', function ($id) { 
      $id = auth()->user()->id; 

      return redirect()->action('[email protected]'); 



     }); 

     Route::post('/', '[email protected]'); 

     Route::post('/edit', '[email protected]'); 



    }); 

UserController.php私のインデックスメソッドが明らかに設定されていても

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 
use Validator; 
use DB; 
use App\User; 
use App\Http\Requests; 
use Session; 

class UserController extends Controller 
{ 
    /** 
    * Display a listing of the resource. 
    * 
    * @return \Illuminate\Http\Response 
    */ 
    public function index() 
    { 
     return view('users.profile'); 
    } 

....それでもエラー浮き出る。エラーを見つけてください。ありがとう!

+0

可能性のある重複した[Laravel 4リダイレクト::アクション()「ルート定義されていません」](HTTP: //stackoverflow.com/questions/21416083/laravel-4-redirectaction-route-not-defined) –

答えて

0

あなたは非既存のルートにリダイレクトしようとしているルートケース

Route::get('/', '[email protected]'); 

ただし、以下の問題をさらに読んでください。

検出された問題

  • route.phpは、なぜあなたは$idでIDを格納し、$ IDで何もせずにindexアクションにリダイレクトん{id}
  • routes.php
  • 変更/{id}すべきですか?
  • あなたのルートパスが非常に明確ではありません(なぜあなたは、更新のために/への投稿を行うのですか?)の
+0

あなたの修正と入力をありがとう! 3番目のポイントは、{id}が$ idを関数に設定することを定義しようとしている私のコードではありませんか? for 4th point、私の更新機能で思ったことだけで、ユーザーが送信したデータを検証し、そのレコードをデータベースで更新します。それはそれをするのは不適切な方法ですか? – warmjaijai

関連する問題