ERROR MODELS
tolgatasci opened this issue · 2 comments
Error
BadMethodCallException in Builder.php line 2508:
Call to undefined method Illuminate\Database\Query\Builder::getAllFriendships()
app/user.php
`<?php
namespace App;
use Hootlex\Friendships\Traits\Friendable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable, Friendable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
My Controller
namespace App\Http\Controllers;
use DB;
use Illuminate\Foundation\Auth\User;
use Illuminate\Http\Request;
use \App\Access_token;
$recipient = User::find(1);
var_dump($recipient->getAllFriendships());`
The problem seems to be your code, not this library. You need to call the method getAllFriendships
on your User instance, not a query builder instance. If you look the import part of your controller, you can see a wrong import :
use Illuminate\Foundation\Auth\User;
instead of
use App\User;
True! thank you.i forget callback