agnonym
TCTwill CMS
•Created by agnonym on 4/18/2023 in #👊support
[3.0.0] Block class - getBlockTitle()
Thx @hro1337 !!
10 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
If you want all your available and published models order by name attribute, and you need slugs to redirect to a Work page and your model has translations, medias and blocks, it should be (not tested)
app(WorkRepository::class)->get(['slugs', 'translations', 'medias', 'blocks'], ['publishedInListings', 'available'], [['name' => 'asc']], -1);
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
But I think you can use the get method of the ModuleRepository, something like that:
app(WorkRepository::class)->get([relations], [scopes like 'publishedInListings', 'available'], [orders], 100)
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
the publishedInListings is a scope that filter published models and checks if you have publication dates (start / end) that the model is visible
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
So, on my frontend controller I usually fetch models like that
$workList = Work::with(potential relations like medias, blocks, slugs, ...)->publishedInListings()->get() or ->paginate(x)
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
Personally, I don't use the Repository for my frontend as if there are breaking changes in Twill package, I don't want to fix all my frontend
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
ok. Twill is headless CMS, all the files created when you create a module if for admin functionalities (Admin Controller, Repository, Request, ...), but it doesn't mean you can't use it for your frontend
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
or is that for our frontend to be used in a controller ?
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
Yep, just wanted to tell you it could be the same feature as you want to achieve with available.
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
Since at least Laravel 4 🙂
19 replies
TCTwill CMS
•Created by undersound on 4/28/2023 in #👊support
Fetch all models with field value of X
Hi @undersound, a good practice is to create a scope on the model (Twill already use this feature to get published models) : https://laravel.com/docs/10.x/eloquent#local-scopes
For example, on your Work class, if you available attribute is a bool:
Then, you can get the available models like that:
For this 'available' need, you could also use the native 'published' feature of Twill
19 replies
TCTwill CMS
•Created by agnonym on 4/18/2023 in #👊support
[3.0.0] Block class - getBlockTitle()
Thanks @hro1337, no hurry, I just wanted to not let the subject die. Let me know if I can do something about this
10 replies
TCTwill CMS
•Created by agnonym on 4/18/2023 in #👊support
[3.0.0] Block class - getBlockTitle()
@hro1337 @ifox.dev sorry to bother you, may you explain me how I can achieve the
@twillBlockTitleField
feature using a Block class?10 replies
TCTwill CMS
•Created by agnonym on 4/18/2023 in #👊support
[3.0.0] Block class - getBlockTitle()
No problem! 😉 What I wanted to do is set a title depending on a Block content value like
@twillBlockTitleField
in Blade forms, but without the Block instance, I don't see how to do it. But maybe is there an other way to do so in Block classes?10 replies
TCTwill CMS
•Created by luciusvorenus_ on 4/14/2023 in #👊support
[3.0.0] componentBlock overriding getBlockIcon doesn't seem to work?
Hi @luciusvorenus_ @ifox.dev , I just had the same problem trying to create a Block class. What I think is getBlockIcon() is never called, I just made a PR: https://github.com/area17/twill/pull/2238
4 replies