0

I have created one plugin using Builder plugin in OctoberCMS and in which I have columns.yaml file.

In a field called property_id, I have a field as VALUE FROM which is asking to add my table's field name hence I have added one called as street_number.

But I want to concat multiple fields there. Something like below.

CONCAT(street_number, ' ', address)

But this is not working. I have also tried with other ways but its still not working.

Can someone guide me how to accomplish this ?

Additionally, It will be great if these fields gets concat if their respective values exists in table.

This is how my columns.yaml file looks like.

columns:
    property_id:
        label: Property
        type: text
        searchable: true
        sortable: false
        relation: Property
        valueFrom: street_number
    start_datetime:
        label: 'Start Date Time'
        type: datetime
        searchable: true
        sortable: true
    end_datetime:
        label: 'End Date Time'
        type: datetime
        searchable: true
        sortable: true
    status:
        label: Status
        type: number
        searchable: true
        sortable: true
        select: 'CASE WHEN (status =  ''1'' ) THEN ''Active'' ELSE ''Inactive'' END'

Thanks

Mittul At TechnoBrave
  • 1,142
  • 3
  • 25
  • 70

2 Answers2

2

Ok Guys,

I have come up with with a solution thanks to a nice suggestion link by Pratyush Pundir above. Here is what I have done to achieve this.

Updated below chunk of code in columns.yaml file.

columns:
    property_id:
        label: Property
        type: property_details
        searchable: true
        sortable: false
        relation: Property

Added type: property_details here.

Opened and updated my Plugin.php file and added below lines.

<?php namespace Technobrave\Homeopenintegration;

use System\Classes\PluginBase;


use technobrave\Properties\Models\Property as Property;


class Plugin extends PluginBase
{


    public function registerListColumnTypes()
        {

            return [
                // A local method, i.e $this->evalUppercaseListColumn()
                'property_details' => [$this, 'evalPropertyDetailsListColumn'],        
            ];
        }


    public function evalPropertyDetailsListColumn($value, $column, $record)
    {
        $current_property = Property::where('id', $record->property_id)->first();
        return $current_property->lot;

    }
}

Thanks for efforts and help.

Community
  • 1
  • 1
Mittul At TechnoBrave
  • 1,142
  • 3
  • 25
  • 70
1

Since there is logic involved here you might just wanna use a custom column type as detailed here https://octobercms.com/docs/backend/lists#custom-column-types. I wouldn't wanna put too much logic inside the yaml file.

EDIT

The OP has added some example code to show exactly what I mentioned above in his comment here.

Community
  • 1
  • 1