Singleton - has no index

Hi, i'm working with twill and i need to create a singleton, but i navigate to the link i get this "Blog has no index" ,i have also done the seeded command, this is my code <?php namespace App\Http\Controllers\Twill; use A17\Twill\Http\Controllers\Admin\SingletonModuleController as BaseModuleController; class BlogController extends BaseModuleController { protected $moduleName = 'blogs'; protected $indexOptions = [ 'permalink' => false, ]; }
15 Replies
ifox
ifox6mo ago
Sounds like you are defining the routes with ::module('blogs') instead of ::singleton('blog'), or using forModule instead of forSingleton in your Twill navigation.
oxana
oxanaOP6mo ago
this is how i have done it Route::name('blogs.posts')->get('blogs/posts'); Route::group(['prefix' => 'blogs'], function () { TwillRoutes::singleton('blog'); TwillRoutes::module('posts'); TwillRoutes::module('categories'); }); TwillNavigation::addLink( NavigationLink::make() ->title('Blogs') ->forRoute('twill.blogs.posts.index') ->doNotAddSelfAsFirstChild() ->setChildren([ NavigationLink::make()->forSingleton('blog')->title('Blog'), NavigationLink::make()->forModule('posts')->title('Posts'), NavigationLink::make()->forModule('categories')->title('Categories'), ]), );
ifox
ifox6mo ago
What's the url where you are getting the error? /blogs/blog?
oxana
oxanaOP6mo ago
yes
ifox
ifox6mo ago
Did you try putting the singleton outside of the blogs prefix?
oxana
oxanaOP6mo ago
i tried it now and i get this Attempt to read property "active" on string
ifox
ifox6mo ago
that's likely unrelated, and I'll need more info about the error to help you, please try to be more explicit. Did you generate this singleton using the CLI?
oxana
oxanaOP6mo ago
yes that's how i generated , this is a image of the error, it shows when i'm at admin/blog
No description
ifox
ifox6mo ago
Is the singleton using HasTranslations?
oxana
oxanaOP6mo ago
yes
ifox
ifox6mo ago
Ok, please show me your model and repository classes for that singleton
oxana
oxanaOP6mo ago
this is the model <?php namespace App\Models; use A17\Twill\Models\Behaviors\HasBlocks; use A17\Twill\Models\Behaviors\HasTranslation; use A17\Twill\Models\Behaviors\HasMedias; use A17\Twill\Models\Behaviors\HasRevisions; use A17\Twill\Models\Model; use CwsDigital\TwillMetadata\Models\Behaviours\HasMetadata; class Blog extends Model { use HasBlocks, HasTranslation, HasMedias, HasRevisions, HasMetadata; protected $fillable = [ 'published', 'title', 'description', ]; public $translatedAttributes = [ 'title', 'description', 'active', ]; public $metadataFallbacks = [ 'title' => 'title', 'description' => 'description', ]; public $slugs = [ 'en' => 'news', 'it' => 'news', ]; public $mediasParams = [ 'cover' => [ 'default' => [ [ 'name' => 'default', 'ratio' => 16 / 9, ], ], 'mobile' => [ [ 'name' => 'mobile', 'ratio' => 1, ], ], 'flexible' => [ [ 'name' => 'free', 'ratio' => 0, ], [ 'name' => 'landscape', 'ratio' => 16 / 9, ], [ 'name' => 'portrait', 'ratio' => 3 / 5, ], ], ], ]; public function getSlugs() { return $this->slugs; } }
oxana
oxanaOP6mo ago
this is the repositery <?php namespace App\Repositories; use A17\Twill\Repositories\Behaviors\HandleBlocks; use A17\Twill\Repositories\Behaviors\HandleTranslations; use A17\Twill\Repositories\Behaviors\HandleSlugs; use A17\Twill\Repositories\Behaviors\HandleMedias; use A17\Twill\Repositories\Behaviors\HandleRevisions; use A17\Twill\Repositories\ModuleRepository; use App\Models\Blog; use CwsDigital\TwillMetadata\Repositories\Behaviours\HandleMetadata; class BlogRepository extends ModuleRepository { use HandleBlocks, HandleTranslations, HandleSlugs, HandleMedias, HandleRevisions, HandleMetadata; public function __construct(Blog $model) { $this->model = $model; } }
ifox
ifox6mo ago
Remove HandleSlugs from the repository since you are not using HasSlug in the model
oxana
oxanaOP6mo ago
yeah, i did that, it works now.Thank you very much!
Want results from more Discord servers?
Add your server