Q:

Laravel "same" code different results

I'm trying to guess what's different in this short code but I can't. One works an the other one returns:
Undefined property: Illuminate\Database\Eloquent\Builder::$join_books 

First method, this one throws error:
public function selectBook(){
    try{
        BookUser::create(Input::all());
        if(!BookUser::userJoinBooks()){
            $user = User::eloquentUser();
            $user->join_books = 1;
            $user->save();
        }
        MyHelpers::sendSessionFlashMessages('El libro ha sido seleccionado', 'bg-success');
    }
    catch (Exception $e) {
        $message = MyHelpers::exceptionCatch($e);
        MyHelpers::sendSessionFlashMessages($message['message'], $message['css-class']);
    }
    return Redirect::back();
}

Two lines after this one I have the unselect method, looks like the same, but works fine:
public function unselectBook(){
    try{
        $book_user = BookUser::find(Input::get('id'));
        $book_user->delete();
        if(BookUser::userBooksCount() == 0){
            $user = User::eloquentUser();
            $user->join_books = 0;
            $user->save();
        }
        MyHelpers::sendSessionFlashMessages('El libro ha sido eliminado', 'bg-success');
    }
    catch (Exception $e) {
        $message = MyHelpers::exceptionCatch($e);
        MyHelpers::sendSessionFlashMessages($message['message'], $message['css-class']);
    }
    return Redirect::back();
}

If I remove from SelectBook method "!BookUser::userJoinBooks()" in the if statement and use if(1) for example, it work's. I dont undestand why if I make the $user asigment after this static method it could be influence it.
This is the static method code:
public static function userJoinBooks($id = null){
    $user_id = $id === null ? Sentry::getUser()->getId(): $id;
    return User::where('id',$user_id)->join_books == 0 ? false : true;
}

And the other one too, may be help:
 public static function userBooksCount($id = null){
    $user_id = $id === null ? Sentry::getUser()->getId(): $id;
    return BookUser::where('user_id',$user_id)->count();
}

And this is the eloquentUser method:
public  static function eloquentUser(){
    $sentry_user = Sentry::getUser();
    return $user = User::findOrFail($sentry_user->id);
}

Really a can't remenber why I use this method, I soppose not to use Sentry::getUser in my code that if at some point I will use another user's library.
Thanks :)

A:

The problem is this part of your code:
return User::where('id',$user_id)->join_books == 0 ? false : true;

I suppose you would want to use something like:
return User::findOrFail($user_id)->join_books == 0 ? false : true;

