hootlex / laravel-friendships

This package gives Eloquent models the ability to manage their friendships.
MIT License
706 stars 151 forks source link

ERROR MODELS #78

Closed tolgatasci closed 7 years ago

tolgatasci commented 7 years ago

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());`

stephane-monnot commented 7 years ago

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;

tolgatasci commented 7 years ago

True! thank you.i forget callback