dimanche 27 septembre 2015

Missing argument 1 for Aries\Http\Controllers\FriendController::getAccept()

So I cant figure out why this isnt passing the variable to my controller.

Heres my /Controllers/FriendController.php getAccept Function:

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.');
    }
}

Heres my blade where the accept friend request button is:

@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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire