Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3k stars 880 forks source link

Calendar operation doesn't support getters #5461

Closed miquelangeld closed 4 months ago

miquelangeld commented 4 months ago

Hi, I'm trying to use calendar operation with a getter defined in my model.

protected $appends = [
        'caption'
    ];

public function getCaptionAttribute(): string
    {
       return $this['title'].' - '.$this['comments'];
    }

In my controller i mapped the title field:

protected function getCalendarFieldsMap(): array
    {
        return ['title' => 'caption'];
    }

In the list view I can use the getter, no problem there, but if I toggle to calendar view the cells doesn't show the entries

image

backpack/backupmanager: v5.0.0 backpack/basset: 1.2.2 backpack/calendar-operation: 1.0.0 backpack/crud: 6.6.3 backpack/devtools: 3.0.4 backpack/editable-columns: 3.0.5 backpack/generators: v4.0.3 backpack/logmanager: v5.0.1 backpack/permissionmanager: 7.1.1 backpack/pro: 2.1.3 backpack/settings: 3.1.0 backpack/theme-coreuiv2: 1.2.3 backpack/theme-coreuiv4: 1.1.1 backpack/theme-tabler: 1.2.0

pxpm commented 4 months ago

Thanks @miquelangeld . It makes sense to use it that way.

I've already created the PR for it. @promatik should review it shortly 🙏

Thanks

pxpm commented 4 months ago

Hey @miquelangeld it's done in version 1.0.3 of Calendar Operation that I just released.

You may allow some time for our private repo to pick it up and a composer update should get you the fix 🙏

Let us know if you find any other issue 🙏

miquelangeld commented 4 months ago

Thanks @pxpm @promatik !!

miquelangeld commented 4 months ago

Hi @pxpm I just tested and doesn't seems to work, now I get a number instead.

image

miquelangeld commented 4 months ago

This is the same getter in list view image So far I have not been able to find out where this number comes from.

pxpm commented 4 months ago

Hum .. something wrong then, I've just tested and it seems to be working as expected: image

protected $appends = [
        'caption'
    ];

    public function getCaptionAttribute(): string
    {
       return $this->title.' - test accessor';
    }

Can you reproduce it in a clean project ?

miquelangeld commented 4 months ago

Yes, let me see.

miquelangeld commented 4 months ago

Ok, I cleared the view cache and now it works.

image

Still shows the number first, which now I see it's the hour but for some reason not shows the full hour (hour and minutes) and just show the hour. But this is another issue, so I will dig in to it. Thanks Pedro and sorry for the inconvenience.

pxpm commented 4 months ago

Not inconvenient at all. If it had an issue I would have liked to know. 👍

Glad it's working! Thanks @miquelangeld 🙏