Closed mostafaznv closed 8 years ago
i can override get() in NestableTrait.php like this:
$this->source = parent::where('post_type','posts')->get();
but if i update the package, all these will gone... @atayahmet
i created NestableTraitPlus now i use my own functions and i think it's a safe way ...
Hi @Mostafa,
I have seen yet the message.
You can already use it.
Category::nested()->where('post_type', 'posts')->get();
What's the problem exactly?
Ohh sorry, I got it now. The problem is output methods. Ok. I will fix it as posibble.
thank you dear ahmet... so, is it safe way to create "NestableTraitPlus" and using new get() function?
or if i should wait for new version, how long does it take?
thanks ...
it works fine only for nested()
but i get these errors for other methods (renderAsDropdown, renderAsHtml):
Call to a member function where() on string
Call to a member function get() on string
edit: i found the problem i changed this:
public static function renderAsHtml()
{
return self::nested(static::$toArray)->get();
}
to:
public static function renderAsHtml()
{
return self::nested(static::$toArray);
}
and when i use $categories = category::renderAsHtml()->where('post_type', 'products')->get();
it works fine
Hi @mostafaznv
Please use such: Category::where('post_type', 'posts')->renderAsHtml();
or
Category::where('post_type', 'posts')->renderAsDropdown();
Not use such:
Category::where('post_type', 'posts')->renderAsDropdown()->get();
but it return all records in my table
$categories = category::where('post_type', 'posts')->renderAsHtml();
I tested the changes and works fine. Share results please.
this is my table: and with this code:
$categories = \App\category::where('post_type', 'posts')->renderAsHtml();
return $categories;
i get below results:
all of records are shown in output...
Hi @mostafaznv
update and try again.
wow ... thanks dear ahmet ... it works fine ...
Thank you too for contribution @mostafaznv .
hi. thanks for your nice package.
i created a custom database like this:
i want to show only categories for a specific post_type can u help me?