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

    void

    07/06/2021, 3:39 PM
    I do something like this in my controllers forSlug method
    Copy code
    php
      public function show($slug)
        {
            $car = $this->carRepository->forSlug($slug);
  • v

    void

    07/06/2021, 3:39 PM
    I will keep it in mind althought build worked already
  • i

    ifox

    07/06/2021, 3:40 PM
    because it would have updated the assets from twill distributed ones, and you wouldn't have had to run the build. yeah all good!
  • v

    void

    07/06/2021, 3:40 PM
    https://twill.io/docs/#cli-generator ---hasSlug
  • p

    pboivin

    07/06/2021, 3:40 PM
    To add to @void 's answer, from anywhere outside of a controller, you could do something like
    $project = app(ProjectRepository::class)->forSlug($slug);
  • v

    void

    07/06/2021, 3:40 PM
    @User thanks that really clarifies some things for me 🙂
  • u

    user

    07/06/2021, 3:41 PM
    Alrihgt
  • u

    user

    07/06/2021, 3:42 PM
    That is what I needed 🙂 Thanks
  • u

    user

    07/07/2021, 8:17 AM
    Can I get a brief explanations about this part of the documentation regarding the
    multi_select
    and the external sectors table? Is the
    sectors
    table mandatory? I mean, is that name just a name for my table which will hold data OR is the
    sectors
    table something that twill convention requires? I mean, is it required in the same sense as the
    medias
    and
    files
    tables?
  • i

    ifox

    07/07/2021, 8:19 AM
    that's an example name
  • u

    user

    07/07/2021, 8:19 AM
    Right, so basically everything related to sectors is just an example, and the table should be my 'REAL' table which would hold the data?
  • i

    ifox

    07/07/2021, 8:19 AM
    yes
  • u

    user

    07/07/2021, 8:20 AM
    Alright, that helps a lot.
  • u

    user

    07/07/2021, 8:44 AM
    hey @ifox, I was wondering, if it's not the proper parameters passed to the
    image()
    method, what else could be the cause of having a
    data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
    output instead of an actual path?
  • u

    user

    07/07/2021, 8:44 AM
    Copy code
    +mediasParams: array:3 [▼
        "carousel_image" => array:3 [▶]
        "seo_image" => array:3 [▶]
        "image" => array:3 [▼
          "desktop" => array:1 [▼
            0 => array:2 [▼
              "name" => "desktop"
              "ratio" => 0
            ]
          ]
          "mobile" => array:1 [▶]
          "flexible" => array:3 [▶]
        ]
      ]
  • u

    user

    07/07/2021, 8:44 AM
    Copy code
    $product->image('image', 'desktop')
  • i

    ifox

    07/07/2021, 8:45 AM
    that should work as long as you also have a medias field with the name image and that you attached an image in that field
  • u

    user

    07/07/2021, 8:45 AM
    Yeah the part above is the dd with the mediaParams linked to the products model
  • i

    ifox

    07/07/2021, 8:47 AM
    so you have
    @formField('medias', ['name' => 'image', ...)
    in your form?
  • u

    user

    07/07/2021, 8:48 AM
    Yup, as:
    Copy code
    @formField('medias', [
            'name' => 'image',
            'label' => 'Product Image',
            'max' => 1,
        ])
  • i

    ifox

    07/07/2021, 8:48 AM
    i think one thing that might be happening to you is crop names conflicts. If you also define an
    image
    role in the block editor configuration with different crop names, you might end up with no
    desktop
    crop.
  • i

    ifox

    07/07/2021, 8:49 AM
    is that field allowing you to do 3 crops?
  • u

    user

    07/07/2021, 8:50 AM
    So, inside
    twill.php
    and inside
    blocks_editor
    Copy code
    'crops'                  => [
                'cover' => [
                    'desktop' => [
                        [
                            'name'      => 'desktop',
                            'ratio'     => 0,
                            'minValues' => [
                                'width'  => 100,
                                'height' => 100,
                            ],
                        ],
                    ],
                    'tablet'  => [
                        [
                            'name'      => 'tablet',
                            'ratio'     => 0,
                            'minValues' => [
                                'width'  => 100,
                                'height' => 100,
                            ],
                        ],
                    ],
                    'mobile'  => [
                        [
                            'name'      => 'mobile',
                            'ratio'     => 0,
                            'minValues' => [
                                'width'  => 100,
                                'height' => 100,
                            ],
                        ],
                    ],
                ],
    
                'image' => [
                    'desktop'  => [
                        [
                            'name'  => 'desktop',
                            'ratio' => 0,
                        ],
                    ],
                    'mobile'   => [
                        [
                            'name'  => 'mobile',
                            'ratio' => 1,
                        ],
                    ],
                    'flexible' => [
                        [
                            'name'  => 'free',
                            'ratio' => 0,
                        ],
                        [
                            'name'  => 'landscape',
                            'ratio' => 0,
                        ],
                        [
                            'name'  => 'portrait',
                            'ratio' => 0,
                        ],
                    ],
                ],
  • i

    ifox

    07/07/2021, 8:52 AM
    hmm you have desktop in both so shouldn't be a problem
  • i

    ifox

    07/07/2021, 8:52 AM
    is the image field saving on your product form?
  • u

    user

    07/07/2021, 8:54 AM
    Yeah. the image gets saved after adding a new product
  • i

    ifox

    07/07/2021, 8:58 AM
    hmm that's weird. do you see the relationship if you dump $product->medias
  • u

    user

    07/07/2021, 9:02 AM
    Copy code
    "pivot" => Illuminate\Database\Eloquent\Relations\MorphPivot {#2587 ▼
              #morphType: "mediable_type"
              #morphClass: "App\Models\Product"
              +incrementing: false
              #guarded: []
              #connection: "mysql"
              #table: "mediables"
              #primaryKey: "id"
              #keyType: "int"
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:15 [▶]
              #original: array:15 [▶]
              #changes: []
              #casts: []
              #classCastCache: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #fillable: []
              +pivotParent: App\Models\Product {#2443 ▶}
              #foreignKey: "mediable_id"
              #relatedKey: "media_id"
            }
  • i

    ifox

    07/07/2021, 9:04 AM
    ok, so first you should be seeing multiple rows in the relationship
  • i

    ifox

    07/07/2021, 9:04 AM
    one per crop
1...484950...484Latest