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

    kalle

    07/01/2022, 1:46 PM
    Yes you can.
  • z

    zoi

    07/01/2022, 2:01 PM
    can you help how to call it in custom page?
  • k

    kalle

    07/01/2022, 2:04 PM
    Can tell me what you have tried already?
  • z

    zoi

    07/01/2022, 2:07 PM
    i tryed this way
  • p

    pboivin

    07/01/2022, 2:34 PM
    Hey @zoi, there's a workaround to enable custom components in custom pages : https://discord.com/channels/811936425858695198/915610590104387584/915677751720169483
  • p

    pboivin

    07/01/2022, 2:35 PM
    You have to make a small change to the
    free.blade.php
    layout
  • z

    zoi

    07/01/2022, 3:08 PM
    thanks it worked
  • s

    Sami

    07/01/2022, 3:40 PM
    Hello! I generated a singleton using
    php artisan twill:make:singleton HomePage -TR
    but I have a trouble seeding it to the database. I'm using one seeder (DatabaseSeeder) and creating the model like this:
    Copy code
    php
    HomePage::create([
        'en' => [
            'title' => 'Homepage',
            'description' => 'Some random description',
            'active' => true,
        ],
        'de' => [
            'title' => 'Hömëpägë',
            'description' => 'Some random description too',
            'active' => true,
        ]
    ]);
    I didn't modify the model (so it's only a basic class generated by Twill), just removed
    published
    from migration and from
    fillable
    I'm getting **TypeError**:
    Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in ..\project\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 886
  • p

    pboivin

    07/01/2022, 3:42 PM
    Hey @Sami, not sure what would cause this error specifically but have you tried seeding through the Repository?
    Copy code
    app(HomePageRepository::class)->create([
        'title' => [
            'en' => '...',
            'de' => '...',
        ],
        
        ...
    ]);
  • s

    Sami

    07/01/2022, 3:46 PM
    this works but not with the syntax langs=>fields
  • s

    Sami

    07/01/2022, 3:48 PM
    doesn't matter that much but Idk what happened it doesn't work anymore. I'm using it on projects with older Twill (2.5 and lowed) and it works there
  • s

    Sami

    07/01/2022, 3:48 PM
    Thanks anyway!
  • d

    dedli

    07/02/2022, 12:47 PM
    Hi guys ) In nested module try to get only documents with depth 2, but get error column depth does not exist.
    Copy code
    Document::withDepth()->having('depth', '=', 2)->get()
    . If I remove having in query I get documents with depth in attributes. My db is Postgres maybe it is a problem https://monosnap.com/file/jKNpi0qmCHezqlHYYUOH3ywCt9OY9a
  • i

    ifox

    07/02/2022, 1:43 PM
    @dedli see the note in the nested set package docs you screenshot: IMPORTANT! This will not work in database strict mode
  • i

    ifox

    07/02/2022, 1:44 PM
    which, I think, means this feature won't work in postgres
  • i

    ifox

    07/02/2022, 1:44 PM
    https://github.com/lazychaser/laravel-nestedset/issues/126#issuecomment-780779755
  • d

    dedli

    07/02/2022, 2:00 PM
    Thanks a lot!!! This works for me. And I know that I should google it myself 😔 Sorry for disterbing
  • d

    dedli

    07/02/2022, 2:07 PM
    Sorry one more question for future. when I pass $scopes paraneter to repository get method, how can I pass addition parameter? If I pass $scopes = ['docs'=>$someParam] I get error that I need to pass two parameters. I thought that $query param pass automatic, if it does not how shoud I path this two parameters?
  • i

    ifox

    07/02/2022, 8:20 PM
    looking at the code that uses those scopes will probably help @dedli https://github.com/area17/twill/blob/f9cd9eee5d07543230d65dd0a5f90ec556363db7/src/Repositories/ModuleRepository.php#L695
  • d

    dedli

    07/03/2022, 4:42 AM
    Thanks, yes I saw it. Am I understand right that it use key ($column) only and didn't use $value at-all when it's custom scope?
  • d

    dedli

    07/03/2022, 6:53 AM
    I redefine getBrowserTableData and set browser preview as I want but selected browser date still contains only title and default image. Is it possible to change this preview? https://monosnap.com/file/reHLwheK8SyQKAArIt04rudqVYdCuH
  • h

    Harings Rob

    07/04/2022, 6:25 AM
    I will have a look at this @dedli
  • h

    Harings Rob

    07/04/2022, 6:27 AM
    You use 2 media fields? Can you share your columns setup?
  • d

    dedli

    07/04/2022, 6:53 AM
    In my document admin controller I redefine method:
    Copy code
    protected function getBrowserTableData($items){    
    $withImage = $this->moduleHas('medias');    
    return $items->map(function ($item) use ($withImage) {
            $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item) {            return $this->getItemColumnData($item, $column);
    })->toArray();        
    $name = $columnsData[$this->titleColumnKey] . ' ('.($columnsData['published']?'актуальний':'архівний').')';        unset($columnsData[$this->titleColumnKey]);        
    return ['id' => $this->getItemIdentifier($item),                'name' => $name,                'edit' => moduleRoute($this->moduleName, $this->routePrefix, 'edit', $this->getItemIdentifier($item)),                'endpointType' => $this->repository->getMorphClass(),            ] + $columnsData + ($withImage && ! array_key_exists('thumbnail', $columnsData) ? [                'thumbnail' => $columnsData['published']?'/theme/images/documents/documents-2.png':'/theme/images/documents/documents-1.png',            ] : []);    })->toArray();}
  • d

    dedli

    07/04/2022, 6:54 AM
    I don't have image in my document so I hardcoded image and add some additional date to $name depends on published/unpublished document
  • h

    Harings Rob

    07/04/2022, 7:03 AM
    oh ok I think I see the issue. But not yet how to solve it.
  • h

    Harings Rob

    07/04/2022, 7:04 AM
    When the page is loaded fresh, it does not go thorough that method.
  • h

    Harings Rob

    07/04/2022, 7:05 AM
    So you need to also apply this in
    getFormFieldsForBrowser
    in your module repository
  • h

    Harings Rob

    07/04/2022, 7:05 AM
    I think
  • h

    Harings Rob

    07/04/2022, 7:05 AM
    or
    getFormFieldsForRelatedBrowser
1...354355356...484Latest