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

Francesco
Francesco

Hi, in my custom plugin at some point, i want to show all the items of type 'exhibitor' i have my component, my page, my model, my data in the db.. every is fine but i can't get the list....

The Component

<?php namespace B33\Conference\Components;

use Cms\Classes\ComponentBase;
use B33\Conference\Models\Exhibitor;

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

    public function defineProperties()
    {
        return [];
    }

    public function exhibitors()
    {   
        $exhibitors = Exhibitor::select( 'id','title', 'slug')->get();    
        return $exhibitors;
    }
}

the model

?php namespace B33\Conference\Models;

use Model;

/**
 * Model
 */
class Exhibitor extends Model
{
    use \October\Rain\Database\Traits\Validation;
    use \October\Rain\Database\Traits\SoftDelete;

    protected $dates = ['deleted_at'];
    protected $jsonable = ['urls'];
    protected $sluggable = ['title'];
    protected $fillable=['title'];

    public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];
    public $translatable = ['teaser', 'body', 'tags', 'urls'];

    /**
     * @var string The database table used by the model.
     */
    public $table = 'b33_conference_exhibitors';

    /**
     * @var array Validation rules
     */
    public $rules = [
    ];

    public $belongsTo = [
        'category' => 'B33\Conference\Models\ExhibitorCategory',
        'distributor' => 'B33\Conference\Models\Exhibitor'
    ];

    public $hasMany = [
        'distributed_brands' => ['B33\Conference\Models\Exhibitor',  'key' => 'distributor_id']
    ];

    public $belongsToMany = [
        'events' => ['B33\Conference\Models\Event', 'table' => 'b33_conference_exhibitor_events'],
        'sessions' => ['B33\Conference\Models\Session', 'table' => 'b33_conference_session_exhibitors'],
        'tags' => ['B33\Conference\Models\ExhibitorTag', 'table' => 'b33_conference_exhibitor_tags_mapping'],
    ];

    public $attachOne = [
        'logo' => ['System\Models\File', 'public' => true]
    ];

}

the page

title = "exhibitors"
url = "/exhibitors"
layout = "main"
is_hidden = 0

[Exhibitors]
==
{% set exhibitors = Exhibitors.exhibitors() %}

{{dump(exhibitors)}}

this one

$exhibitors = Exhibitor::select( 'id','title', 'slug')->get();    

produce this query in the debug toolbar

select `id`, `title`, `slug` from `b33_conference_exhibitors` where `b33_conference_exhibitors`.`deleted_at` is null

this query in phpmyadmin works!

but if i dump the exhibitors variable in the htm file, i get nothing...

Last updated

1-1 of 1

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