0

I'm building an job application plug-in in OctoberCms. Now only 1 of the 2 items apear on the front-end. I would like all the items to display. But now I can only select 1 by imput the id in the backend at the component propperty

I have to add this$properties = $this->getProperties(); somewhere in my code but I can't figure out where. any suggestions?

php namespace Hessel\Vacatures\Components;

use Cms\Classes\ComponentBase;
use Hessel\Vacatures\Models\Vacature as VacatureModel;

class vacature extends ComponentBase
{

    public function componentDetails()
    {
        return [
            'name'        => 'Vacature Component',
            'description' => 'No description provided yet...'
        ];
    }

     public function defineProperties()
    {
        return [
            'vacatureId' => [
                'title'        => 'Vacature'

            ],
        ];

    }

     public function getVacatureIdOptions()
    {
        return VacatureModel::select('id', 'title')->orderBy('title')->get()->lists('title', 'id');
    }

    public function onRender()
    {
        $this->vacature = $this->page['vacature'] = VacatureModel::where('id', '=', $this -> property('vacatureId')) -> first();

    }

}





1 Answers1

0

in the onRender() you use ->first() at the end. if you change this to ->get() This returns an Object with all values for each row. you should loop through it to print them out ofcourse.

public function onRender()
{
    $object = VacatureModel::where('id', '=', $this -> property('vacatureId')) -> get();
}

foreach($object as $key => $value){ echo $value->id; }