This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

mittul
mittul

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.

Thanks

norotaro
norotaro

Maybe you can create a "virtual attribute" and show it in your list.

For example in your columns.yaml:

columns:
    (...)
    full_address:
        label: Full address
        sorteable: false
        valueFrom: full_address

And in your model:


<?php namespace Author\Plugin\Models;
use Model;

class MyModel extends Model
{
    (...)

    public function getFullAddressAttribute() {
        return $this->street_number . ' ' .$this->address;
    }
}
mittul
mittul

Ok Guys,

I have come up with with a solution. 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.

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.