vendredi 25 septembre 2015

Call to a member function isATeamManager() on a non-object

Getting this error "Call to a member function isATeamManager() on a non-object".some one kindly give me the solution.


(RedirectIfNotAManager.php)

<?php

namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;


class RedirectIfNotAManager
{


    public function handle($request, Closure $next)
    {
        if(!$request->user()->isATeamManager())
        {

            return redirect('articles');

        }

        return $next($request);
    }
}

I have googled it and didn't get any solution,since i am new to laravel kindly help me to solve this problem .its in laravel 5.1 . I have tried other examples and still getting this error..

(This is the User.php Model code:)

<?php

namespace App;


class User extends Model implements AuthenticatableContract,
                                    AuthorizableContract,
                                    CanResetPasswordContract
{
    use Authenticatable, Authorizable, CanResetPassword;

     protected $table = 'users';


    protected $fillable = ['name', 'email', 'password'];


    protected $hidden = ['password', 'remember_token'];


    public function articles()

    {


        return $this->hasMany('App\Article');
    }

    public function isATeamManager()
    {

        return false;
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire