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

    Dmi3yy

    05/19/2021, 10:58 AM
    and what different capsule from just module ? only what we can do direct link in admin panel ?
  • i

    ifox

    05/19/2021, 11:24 AM
    capsules are about the files structure @Dmi3yy, instead of a module where each file is placed at the appropriate location in your laravel codebase, capsules have all files in a single folder, which is installable through remote repositories
  • i

    ifox

    05/19/2021, 11:25 AM
    that specific capsule focuses on setting up a module to manage a unique homepage
  • i

    ifox

    05/19/2021, 11:25 AM
    https://github.com/area17/twill-capsule-homepages/blob/868c6bd73f41c303b36dcac146cfdc16e624e38e/routes/admin.php#L7
  • i

    ifox

    05/19/2021, 11:25 AM
    it registers a dedicated route to be able to link directly to the form from the CMS navigation
  • d

    Dmi3yy

    05/19/2021, 11:26 AM
    thanks, understand )
  • d

    Dmi3yy

    05/19/2021, 5:53 PM
    Do modules have a copy function?
  • d

    Dmi3yy

    05/19/2021, 5:54 PM
    it is often easier to make a copy of a document and make changes to it than to create from scratch
  • a

    antonioribeiro

    05/19/2021, 5:55 PM
    Did you try
    protected $indexOptions = [ 'duplicate' => true ];
    ?
  • d

    Dmi3yy

    05/19/2021, 5:57 PM
    need add in docs:
  • d

    Dmi3yy

    05/19/2021, 5:57 PM
    https://twill.io/docs/#controllers - not present in this sample 😦
  • a

    antonioribeiro

    05/19/2021, 5:57 PM
    Can you please create an issue to add it to the docs?
  • d

    Dmi3yy

    05/19/2021, 5:57 PM
    and where is the documentation stored? can I send a pull request there?
  • d

    Dmi3yy

    05/19/2021, 5:58 PM
    yep
  • a

    antonioribeiro

    05/19/2021, 5:58 PM
    https://github.com/area17/twill/tree/2.x/docs/.sections
  • d

    Dmi3yy

    05/19/2021, 6:07 PM
    Thanks ) first PR done:)
  • d

    Dmi3yy

    05/19/2021, 6:19 PM
    and one more question try show in list related column
    Copy code
    'category' => [ 
                'title' => 'Категория',
                'sort' => true,
                'relationship' => 'category',
                'field' => 'title',
                'visible' => true,
            ],
    in debugbar i see info: https://tppr.me/P1QIi and inside all ok https://tppr.me/rRCA4
  • d

    Dmi3yy

    05/19/2021, 6:20 PM
    have table categories and for relations: category_program
  • r

    Rayderxx

    05/19/2021, 6:24 PM
    'relationship' => 'category', => 'relationship' => 'category_program',
  • r

    Rayderxx

    05/19/2021, 6:24 PM
    maybe ? 😮
  • i

    ifox

    05/19/2021, 6:25 PM
    yeah I was going to ask, how's your relationship looking in the model
  • d

    Dmi3yy

    05/19/2021, 6:27 PM
    if relationship not category, this column hide from the list
  • d

    Dmi3yy

    05/19/2021, 6:30 PM
    Copy code
    public function categories()
        {
            return $this->belongsToMany(\App\Models\Category::class);
        }
  • r

    Rayderxx

    05/19/2021, 6:31 PM
    ah ok this a belongsToMany not a belongsTo
  • r

    Rayderxx

    05/19/2021, 6:31 PM
    You should use a presenter to display it
  • i

    ifox

    05/19/2021, 6:32 PM
    ah yeah if you want the listing to show multiple related records you'd use a presenter
  • d

    Dmi3yy

    05/19/2021, 6:33 PM
    Copy code
    'presenterMethodField' => [ // presenter column
                'title' => 'Field title',
                'field' => 'presenterMethod',
                'present' => true,
            ]
    and add presenterMethod method to model?
  • r

    Rayderxx

    05/19/2021, 6:34 PM
    Yes
  • r

    Rayderxx

    05/19/2021, 6:35 PM
    And if you want to sort the field in the list you will have to build the query yourself il the repository
  • r

    Rayderxx

    05/19/2021, 6:40 PM
    Copy code
    <?php
    namespace App\Models\Presenters;
    
    class JobPresenter
    {
        protected $entity;
    
    
        public function __construct($entity)
        {
            $this->entity = $entity;
        }
    
        public function __get($property)
        {
            if (method_exists($this, $property)) {
                return $this->{$property}();
            }
            return $this->entity->{$property};
        }
    
        public function sectors()
        {
            return  $this->entity->sectors->implode('title', '<br/>');
        }
    }
1...678...484Latest