https://twill.io logo
Join Discord
Powered by
# ❓questions
  • l

    Luís Novais

    07/04/2021, 3:55 PM
    Hi, how can I do a page like that ? https://demo.twill.io/about Any tutorial for do that ?
  • p

    pboivin

    07/04/2021, 4:05 PM
    Hey @User , you could use a standard module but with only one row in the database, and no index in the CMS. A "single page module", so to speak.
  • p

    pboivin

    07/04/2021, 4:05 PM
    Quick example : https://github.com/area17/twill/discussions/1034
  • l

    Luís Novais

    07/04/2021, 4:09 PM
    Thanks for your time and help
  • u

    user

    07/04/2021, 9:26 PM
    Ill give it a quick look now
  • u

    user

    07/04/2021, 9:26 PM
    It looks like they loaded automaticly from twill package
  • u

    user

    07/04/2021, 9:35 PM
    Copy code
    SQLSTATE[42S02]: Base table or view not found: 1146 Table '{PROJECT}.taggables' doesn't exist (SQL: select `tags`.*, `taggables`.`taggable_id` as `pivot_taggable_id`, `taggables`.`tag_id` as `pivot_tag_id`, `taggables`.`taggable_type` as `pivot_taggable_type` from `tags` inner join `taggables` on `tags`.`id` = `taggables`.`tag_id` where `taggables`.`taggable_id` = 1 and `taggables`.`taggable_type` = posts order by `order_column` asc) (View: D:\laragon\www\{PROJECT}\vendor\area17\twill\views\partials\form\_tags.blade.php)
    My Model:
    Copy code
    php
    class Post extends Model
    {
        use HasBlocks, HasSlug, HasMedias, HasRevisions, HasTags;
        ...
    }
    My Repository:
    Copy code
    php
    class PostRepository extends ModuleRepository
    {
        use HandleBlocks, HandleSlugs, HandleMedias, HandleRevisions, HandleTags;|
        ...
    }
    Add the end off my form file
    @formField('tags')
  • i

    ifox

    07/04/2021, 9:40 PM
    remove
    HasTags
    from your model
  • i

    ifox

    07/04/2021, 9:41 PM
    thats not from Twill and is looking for a different table
  • u

    user

    07/05/2021, 11:33 AM
    hey there, I was wondering what did I do wrong in order to get this string, instead of path when retrieving media via
    image()
    method?
  • i

    ifox

    07/05/2021, 11:34 AM
    Hey @User, most likely you're not passing the right parameters according to your $mediasParams config
  • u

    user

    07/05/2021, 11:36 AM
    Yup, that was the case. Thanks
  • u

    user

    07/05/2021, 1:23 PM
    What would be the proper way to pass data to a
    form.blade.php
    from a different module? e.g. if I had a model1 where I created some dynamic data, and wanted to add that data to a form to model2 as a list of options for example?
  • p

    pboivin

    07/05/2021, 1:31 PM
    Quick example from the docs: https://twill.io/docs/#multi-select-with-dynamic-values This allows you to fill your
    multi_select
    options with all records from another module.
  • u

    user

    07/05/2021, 1:34 PM
    So basically if I had fields from 3 different models, I would have to make migrations for three separate sector_tables? e.g. post_sector_table, comment_sector_table, user_sector_table? While connecting them to sectors module? @User
  • p

    pboivin

    07/05/2021, 1:36 PM
    Yes and no... hehe. Actually, I guess depends on how you want to store the data (the user selected options) in your DB. If you want actual relational data, you're better off with pivot tables. Otherwise, you can store it in a JSON field or something similar.
  • u

    user

    07/05/2021, 1:37 PM
    So, I can avoid sectors table altogether if I were to add a new column for each of the additional models, and store them as json inside the respective table?
  • i

    ifox

    07/05/2021, 1:38 PM
    yup, there are a bunch of options, pivot, JSON columns, foreign key, polymorphic tables, or even the built in polymorphic
    related
    table.
  • i

    ifox

    07/05/2021, 1:38 PM
    what kind of relationship are you trying to create between those models?
  • u

    user

    07/05/2021, 1:39 PM
    It should be a one to many, since I'm supposed to create several checkboxes and have all of them saved as a single entry for that model.
  • p

    pboivin

    07/05/2021, 1:39 PM
    Totally! The built-in
    related
    is my new favorite ATM 🙂
  • u

    user

    07/05/2021, 1:40 PM
    You might remember the reactions I mentioned the other day? Well, I'd like to allow certain reactions for certain types of posts, so basically I'd just 'mark' reactions which are appropriate to be shown on the user-side.
  • u

    user

    07/05/2021, 1:40 PM
    While making reactions dynamic and being able to add as many as possible on another part of the CMS.
  • i

    ifox

    07/05/2021, 1:44 PM
    right. so first you can get the data from a module inside of the form of another one by either doing it directly from the view (not great), or by adding the
    formData($request)
    function to your module controller. Something like:
    app(ReactionRepository::class)->list All('title')
    will give you back a list that our selection form fields can take as options
  • u

    user

    07/05/2021, 1:45 PM
    Right, and then I'd just return the value as an array back to the form. But what happens to saving the data itself? I'll just add another field to the initial model (which will have several checkboxes) And just let twill handle the rest? I mean after adding it to fillable field list.
  • i

    ifox

    07/05/2021, 1:46 PM
    you might need to call something in the repository too, depending on the approach you take
  • u

    user

    07/06/2021, 10:14 AM
    Thanks it worked! Sorry for late reply was quite busy with stuff, didnt had time to reach my pc.
  • u

    user

    07/06/2021, 10:15 AM
    I do have a thumbnail set but it is not displaying when editing. Is that possible?
    Copy code
    @formField('medias', [
            'name' => 'thumbnail',
            'label' => 'Thumbnail Image'
        ])
  • i

    ifox

    07/06/2021, 10:29 AM
    what do you mean by "I do have a thumbnail set"? after saving and reloading the form it's gone? did you define
    thumbnail
    in your model's
    mediasParams
    ?
  • u

    user

    07/06/2021, 10:32 AM
    Nah I mean that when I edit the
    post
    I would like to see the thumbnail
1...444546...484Latest