@return \Illuminate\Database\Eloquent\Builder
*/
public function ScopeByResourceIdAndUserId($query, $resourceId, $user_id)
{
return $query->where([
['external_id', '=', $resourceId],
['user_id', '=', $user_id]
]);
}
/**
The tags that belong to the book.
*/
public function tags()
{
return $this->belongsToMany('App\EntityTags', 'books_has_entity_tags');
}
}
`
and controller method index that work like this
public function index(Request $request) { $show_publish = ($request->query('show_publish', '0') != '1') ? false : true; $show_approved = ($request->query('show_approved', '0') != '1') ? false : true; $books = ($show_publish) ? Books::WithNotPublished() : Books::WithoutNotPublished(); //$books = ($show_approved) ? $response = $this->processResponse($books->get()); return $response->success(); }
my issue is this
i get this error
BadMethodCallException
Call to undefined method App\Books::WithoutNotPublished()
http://backend.booksurf.local/api/books
Hide solutions
Bad Method Call
Did you mean App\Books::isNotPublished() ?
i got a model that look like this `<?php
namespace App;
use Cog\Flag\Traits\Classic\HasApprovedFlag; use Cog\Flag\Traits\Classic\HasPublishedFlag; use Illuminate\Database\Eloquent\Model;
class Books extends Model { use HasApprovedFlag, HasPublishedFlag; /**
@var array */ protected $guarded = ['external_id'];
/**
@return \Illuminate\Database\Eloquent\Builder */ public function ScopeByResourceExternalId($query, $uuid) { return $query->where('external_id', $uuid); }
/**
@return \Illuminate\Database\Eloquent\Builder */ public function ScopeByResourceIdAndTagsName($query, $tagsNamesArr) { return $query->whereIn('id', $this->tags()->whereIn('name', $tagsNamesArr)->select('book_id') ); }
/**
@return \Illuminate\Database\Eloquent\Builder */ public function ScopeByResourceIdAndUserId($query, $resourceId, $user_id) { return $query->where([ ['external_id', '=', $resourceId], ['user_id', '=', $user_id] ]); }
/**
and controller method index that work like this
public function index(Request $request) { $show_publish = ($request->query('show_publish', '0') != '1') ? false : true; $show_approved = ($request->query('show_approved', '0') != '1') ? false : true; $books = ($show_publish) ? Books::WithNotPublished() : Books::WithoutNotPublished(); //$books = ($show_approved) ? $response = $this->processResponse($books->get()); return $response->success(); }
my issue is this i get this error BadMethodCallException Call to undefined method App\Books::WithoutNotPublished() http://backend.booksurf.local/api/books Hide solutions Bad Method Call Did you mean App\Books::isNotPublished() ?
what do i do wrong what i did miss readed?