https://twill.io logo
Join DiscordCommunities
Powered by
# ❓questions
  • i

    ifox

    01/10/2023, 1:03 PM
    https://github.com/area17/twill/issues/1961
  • e

    elkex

    01/10/2023, 1:27 PM
    Solved!
  • k

    Koili

    01/10/2023, 2:19 PM
    Hey, been enjoying using Twill for a couple of weeks now, and have ended up with me writing a test suite for some of the content variations. Im trying to pre-seed a non-singleton module that has slugs, however I cant find anything in the docs about how slugs interacts with the module repository. Example: The seeder that im trying to write (Should generate a Page model with translated slugs):
    Copy code
    php
    use App\Models\Page;
    use App\Repositories\PageRepository;
    use Illuminate\Database\Seeder;
    
    class PageFaqSeeder extends Seeder
    {
        public function run()
        {
            app(PageRepository::class)->create([
                'published' => true,
                'title' => 'Frequently asked questions',
                'description' => 'Frequently asked questions',
            // should i pass something like 'slugAttributes' here? what should the attributes contain?
            ]);
        }
    }
    The page repository is just the default twill repository that gets generated with composer
    Copy code
    php
    //.. skipped imports
    class PageRepository extends ModuleRepository
    {
        use HandleBlocks, HandleTranslations, HandleSlugs, HandleMedias;
    
    // should i add some overrides to HandleSlugs here?
        public function __construct(Page $model)
        {
            $this->model = $model;
        }
    }
    And the model itself is the default one that gets generated when making a module with translations, blocks slugs and medias. I tried inspecting the HandleSlugs behaviours but cant seem to make sense of it. In short: Seeder doesnt generate localized slug entry in DB, because i dont know how to pass slug name/localisations to the repository.
  • h

    Harings Rob

    01/10/2023, 2:23 PM
    Hey @Koili this is in twill 3?
  • k

    Koili

    01/10/2023, 2:23 PM
    2
  • h

    Harings Rob

    01/10/2023, 2:24 PM
    Ok, anyway, it should be the same for both, but you have to pass in the slug indeed.
    Copy code
    php
                'slug' => ['en' => 'my-title'],
  • i

    ifox

    01/10/2023, 2:30 PM
    It should be generated automatically if you were passing an array of locales into 'title', since your model is translated
  • k

    Koili

    01/10/2023, 2:34 PM
    ok thats probabbly it, since i wasnt translating the title
  • k

    Koili

    01/10/2023, 2:34 PM
    since passing the 'slug' either doesnt do anything or returns an
    array to string conversion
    error
  • e

    Erwin

    01/10/2023, 2:35 PM
    Im having some trouble making a block class, my block is functional. My block class is located in app/Twill/Block folder and is called VacArchiveBlock.php, my block is located in recources/views/admin/blocks and is called vac_archive.blade.php This is my class code:
    Copy code
    <?php
    
    namespace App\Twill\Block;
    
    use A17\Twill\Services\Blocks\Block;
    
    class VacArchiveBlock extends Block
    {
        public function getData(array $data, \A17\Twill\Models\Block $block): array
        {
            $data = parent::getData($data, $block);
    
            dd($data);
    
            return $data;
        }
    }
    Its not going thru the class, does anyone have tips on how i could get this working?
  • k

    Koili

    01/10/2023, 2:35 PM
    yep this one works
  • k

    Koili

    01/10/2023, 2:35 PM
    Thanks @Harings Rob @ifox
  • h

    Harings Rob

    01/10/2023, 2:41 PM
    I am going to check this real quick
  • e

    Erwin

    01/10/2023, 2:42 PM
    FYI: I'm working on a headless project and building my own API so getting the blocks with
    $this->blocks()->get()
  • i

    ifox

    01/10/2023, 2:49 PM
    ha that makes sense then, getData is called in the
    renderBlocks
    context
  • h

    Harings Rob

    01/10/2023, 2:50 PM
    yes correct, it only works when rendering.
  • e

    Erwin

    01/10/2023, 3:32 PM
    Thanks, what would you recommend if i want to use a block controller in this context?
  • i

    ifox

    01/10/2023, 3:37 PM
    You could map the collection and call the corresponding class method
  • l

    Linq2

    01/11/2023, 11:21 AM
    First time user, just having a look at installing it on a new laravel project, do you install it on a basic Laravel install or with Jetstream or Breeze? or does it not matter?
  • i

    ifox

    01/11/2023, 11:24 AM
    Hi @Linq2 it doesn't matter, as in, you can use Twill in pretty much any Laravel application without conflicts with other packages (there are certainly exceptions to that, but definitely not a problem with Jetstream or Breeze)
  • l

    Linq2

    01/11/2023, 11:34 AM
    If I'm building a site using this, this has it's own admin with role, permissions etc..., so I don't need to install Jetstream or Breeze to handle the login
  • k

    kalle

    01/11/2023, 11:38 AM
    For the CMS no you dont need it. If you need it for the frontend usage, you can use these packages.
  • l

    Linq2

    01/11/2023, 11:38 AM
    thanks, that is what I was trying to figure out.
  • l

    Linq2

    01/11/2023, 11:49 AM
    just installed it, added the admin url to .env and got the following error when logging in https://flareapp.io/share/J7oqxWGm#F59
  • k

    kalle

    01/11/2023, 11:51 AM
    Well known first time install error. Check this issue https://github.com/area17/twill/issues/1530#issuecomment-1378591555
  • l

    Linq2

    01/11/2023, 11:54 AM
    Thanks, sorted it, maybe on the documentation it might be worth while stating in ->.env -> 'Accessing the admin console' section , YOU NEED TO SET UP Media Library first, before accessing admin console.
  • i

    ifox

    01/11/2023, 12:58 PM
    Agreed, but we've completely removed this issue from Twill 3 by defaulting to a local setup that doesn't need to be configured on the first install 🙂 btw if you're just starting your journey into Twill, you should use Twill 3, we just release RC2 and the stable is going to be launched very soon
  • j

    jefsev

    01/11/2023, 1:08 PM
    Hi, I just installed twill 2 into an existing project. I used twill about 6 times for other projects from scratch which works great every time. But now in an existing project I get the following error: Symfony\Component\ErrorHandler\Error\FatalError Could not check compatibility between Spatie\Activitylog\Models\Activity::getExtraProperty(string $propertyName, ?Spatie\Activitylog\Models\mixed $defaultValue = NULL): Spatie\Activitylog\Models\mixed and Spatie\Activitylog\Contracts\Activity::getExtraProperty(string $propertyName, Spatie\Activitylog\Contracts\mixed $defaultValue): Spatie\Activitylog\Contracts\mixed, because class Spatie\Activitylog\Models\mixed is not available Tried several things but no luck. edit: this is after i login.
  • j

    jefsev

    01/11/2023, 1:09 PM
    Another question, is there a seperate doc for twill 3? I'm curious as to what the requirments for twill 3 are. 🙂
  • i

    ifox

    01/11/2023, 1:19 PM
    Hi @jefsev there are entirely new docs coming but most content is here https://twill.io/docs/3.x/. You can see all the new docs content at https://github.com/area17/twill/tree/3.x/docs/content. Regarding your error, do you have spatie/activity-log installed in your project already?
1...443444445...484Latest