2015-09-28 59 views
1

所以我無法弄清楚爲什麼這不是將變量傳遞給我的控制器。對Aries Http Controllers FriendController缺少參數1 :: getAccept()

我的繼承人/Controllers/FriendController.php getAccept功能:

public function getAccept($username) 
    { 
     $user = User::where('username', $username)->first(); 
     if (!$user) { 
      return redirect()->route('home')->with('info', 'That user could not be found!'); 
     } 

     if (!Auth::user()->hasFriendRequestRecieved($user)) { 
      return redirect()->route('home'); 
     } 

     Auth::user()->acceptFriendRequest($user); 

     return redirect()->route('profile.index', ['username' => $user->username])->with('info', 'Friend request acccepted.'); 
    } 
} 

我的繼承人刀片在接受好友請求按鈕是:

@extends('templates.default') 

@section('content') 
    <div class="row"> 
     <div class="col-lg-5"> 
      @include('user.partials.userblock') 
      <hr> 
     </div> 
     <div class="col-lg-4 col-lg-offset-3"> 
      @if (Auth::user()->hasFriendRequestPending($user)) 
       <p>Waiting for {{ $user->getNameOrUsername() }} to accept your request.</p> 
      @elseif (Auth::user()->hasFriendRequestRecieved($user)) 
       <a href="{{ route('friends.accept', ['username' => $user->username]) }}" class="btn btn-primary">Accept friend request</a> 
      @elseif (Auth::user()->isFriendWith($user)) 
       <p>You and {{ $user->getNameOrUsername() }} are friends.</p> 
      @else 
       <a href="{{ route('friends.add', ['username' => $user->username]) }}" class="btn btn-primary">Add as friend</a> 
      @endif 

      <h4>{{ $user->getFirstNameOrUsername() }}'s friends.</h4> 
      @if (!$user->friends()->count()) 
       <p>{{ $user->getFirstNameOrUsername() }} has no friends.</p> 
      @else 
       @foreach ($user->friends() as $user) 
        @include('user/partials/userblock') 
       @endforeach 
      @endif 
     </div> 
    </div> 
@stop 

回答

0

好,我解決了這個問題我自己,留下了一個變量在路由所以現在我的路由看起來是這樣的:

Route::get('friends/accept/{username}', [ 
    'uses' => '\Aries\Http\Controllers\[email protected]', 
    'as' => 'friends.accept', 
    'middleware' => ['auth'], 
]); 

忘了:

{username}