https://twill.io logo
Join Discord
Powered by
# 🟠laravel-php
  • h

    Harings Rob

    11/30/2022, 6:38 PM
    It will @amargoCactus friday
  • a

    amargoCactus

    11/30/2022, 6:38 PM
    Thanks
  • i

    ifox

    11/30/2022, 10:14 PM
    That's a smart suggestion @pboivin, I like it
  • h

    Hip-Hop

    12/29/2022, 9:26 AM
    Good afternoon! Has anyone solved the problem of the following character? If the news section. There is a main page which consists of blocks. In one block, news are selected through the browser component. Then I save it and everything works fine. And if I remove the news from the publication after I saved the block with the news, then this news is still saved in the block. Since the database stores an array with keys.
  • i

    ifox

    01/09/2023, 3:33 PM
    Hi @Hip-Hop sorry for the delay. The reference in the block does not look at the publication state to decide whether it should keep it or not, because it is a valid use case to add draft content to a browser field so that when it gets published it is automatically showing elsewhere on the frontend. It is your responsibility to make sure you're not rendering published content.
  • i

    ifox

    01/09/2023, 3:34 PM
    Nice PHPStorm updates coming up https://blog.jetbrains.com/phpstorm/2023/01/what-s-next-in-phpstorm-the-2023-1-public-roadmap/
  • h

    Harings Rob

    01/09/2023, 3:38 PM
    Performance improvements are alwyas nice!
  • i

    ifox

    01/09/2023, 3:39 PM
    Also auto configuration of tools
  • i

    ifox

    01/09/2023, 3:40 PM
    > Automattiс configuration of local setup > Currently, when you open a project for the first time, you may need to configure a few things manually. For example, you may have to specify the PHP interpreter or set up quality tools and other third-party integrations. > We’d like to automate as much of this configuration as possible for you. Ideally, you would just need to open a project and run
    composer install
    from the terminal or PhpStorm, and the rest would be configured for you.
  • h

    Harings Rob

    01/09/2023, 3:45 PM
    I had the idea it already did this
  • h

    Harings Rob

    01/09/2023, 3:45 PM
    but maybe it goes so automatic for me I do not even notice I am doing it
  • a

    amargoCactus

    01/28/2023, 3:10 AM
    Has anyone had this happen before? suddenly now the assets do not load, it is not a 404
  • a

    amargoCactus

    01/28/2023, 3:23 AM
    this is
    php artisan serve
  • i

    ifox

    04/22/2023, 9:48 AM
    Twill mentioned in this month's "PHP Annotated" article on the JetBrains PHPStorm blog, very cool 😎 https://blog.jetbrains.com/phpstorm/2023/04/php-annotated-april-2023/
  • d

    devtutorum

    05/10/2023, 1:46 PM
    Thought this was worth a mention, not sure if this is the correct thread tho. I ran PHP parallel-lint on all files including vendor files and this is an error that popped up in the area17/twill vendor.

    https://cdn.discordapp.com/attachments/811986493245227028/1105853338559455262/image.png▾

  • i

    ifox

    05/10/2023, 1:49 PM
    Hi @devtutorum these files are used by our documentation, they are not meant to be valid
  • i

    ifox

    05/10/2023, 1:51 PM
    in Twill 3 we are excluding the docs source from being downloaded in your vendor folder, so you shouldn't run into this anymore. I'm curious why you would want to lint vendor files though?
  • k

    kalle

    05/10/2023, 1:56 PM
    By docs of this package it seems that it scans whole working directory including
    vendor
    dir. So its best to exclude that dir via argument.
    --exclude vendor
  • d

    devtutorum

    05/10/2023, 2:10 PM
    Was just trying out the tool, curious
  • j

    JeanSilva

    05/12/2023, 7:48 PM
    I am fiddling with validation rules in laravel. I have a model that has a required field, for example,
    name
    . Name must not be null, but the user can update its value. I'm trying to set up a way to validate when this field exists in the request, but if it is null, the validator catches it and throws an error. Is this possible?
  • p

    pboivin

    05/12/2023, 8:20 PM
    Have you tried
    'name' => 'sometimes|required'
    ?
  • p

    pboivin

    05/12/2023, 8:21 PM
    sometimes
    will trigger the rest of the validation only when the field is present in the request
  • j

    JeanSilva

    05/12/2023, 8:55 PM
    thanks 🙂
  • p

    pboivin

    05/25/2023, 1:08 PM
    Catching up on HN threads, I found this quick mention of Twill in the comments: https://news.ycombinator.com/item?id=35899074
  • i

    ifox

    05/25/2023, 1:12 PM
    Nice! > Twill is only one that's Apache License 2.0 > Twill for example really depends on Laravel and feels more deeply integrated with it
  • s

    Scottnj

    05/26/2023, 2:55 PM
    I'm not sure if this is a Twill or Laravel question. I setup a Projects and a Links module. A Project has-many links, a link belongs-to a project. To do this, I followed the one to many example in the docs https://twillcms.com/docs/relations/one-to-many.html All that is working as expected. Next, I wanted to learn how to automatically create a link when a project is created. This gist https://gist.github.com/pboivin/d20d23ae130ea9a112ee49dd98f00239 Has a section that says: > Use the model's booted() method to hook into the created event. > When a user is created through the Laravel Breeze user registration form, > automatically create and assign a Profile record: I so added this to my Project model.
    Copy code
    php
        protected static function booted()
        {
            static::created(function ($project) {
                $project->links()->create([
                    'published' => true,
                    'title' => 'auto generated',
                    'url' => 'https://google.com',
                ]);
            });
        }
    When this code is run, the new link database entry has the correct project_id set, but it also has a deleted_at value set. Why is deleted_at getting set? Is this the correct way to automatically generate a child on creation of a parent?
  • s

    Scottnj

    05/26/2023, 2:56 PM
    If I use
    Copy code
    Link::make()
    and include the project_id, it behaves exactly as
    Copy code
    $project->links()->create()
    . If I comment out the project_id line, the project_id will obviously be null, but now the deleted_at is also null (as it should be).
    Copy code
    php
    $link = Link::make();
    $link->published = true;
    $link->title = 'generated title';
    $link->url = 'https://google.com';
    // $link->project_id = $project->id;
    $link->save();
    Here is a git repo showing this behavior. https://github.com/scottnj/example-app/blob/main/app/Models/Project.php How can I set the project_id, without setting deleted_at?
  • a

    agnonym

    05/26/2023, 3:02 PM
    Hi @Scottnj did you try without the updateRepeater() call in your ProjectRepository?
  • a

    agnonym

    05/26/2023, 3:03 PM
    It's only my opinion, but I would create the link in my ProjectRepository, or through an event / listener
  • s

    Scottnj

    05/26/2023, 3:06 PM
    Removing the updateRepeater() fixed it!!! Thank you!