<?php
declare(strict_types=1);

namespace App\Model\Table;

use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;

/**
 * SectionBannerAssoc Model
 *
 * @property \App\Model\Table\BannersTable&\Cake\ORM\Association\BelongsTo $Banners
 *
 * @method \App\Model\Entity\SectionBannerAssoc newEmptyEntity()
 * @method \App\Model\Entity\SectionBannerAssoc newEntity(array $data, array $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc[] newEntities(array $data, array $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc get($primaryKey, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc findOrCreate($search, ?callable $callback = null, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc[] patchEntities(iterable $entities, array $data, array $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc[]|\Cake\Datasource\ResultSetInterface|false saveMany(iterable $entities, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc[]|\Cake\Datasource\ResultSetInterface saveManyOrFail(iterable $entities, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc[]|\Cake\Datasource\ResultSetInterface|false deleteMany(iterable $entities, $options = [])
 * @method \App\Model\Entity\SectionBannerAssoc[]|\Cake\Datasource\ResultSetInterface deleteManyOrFail(iterable $entities, $options = [])
 */
class SectionBannerAssocTable extends Table
{
    /**
     * Initialize method
     *
     * @param array $config The configuration for the Table.
     * @return void
     */
    public function initialize(array $config): void
    {
        parent::initialize($config);

        $this->setTable('section_banner_assoc');
        $this->setDisplayField(['id']);
        $this->setPrimaryKey(['id']);

        $this->belongsTo('Banners', [
            'foreignKey' => 'banner_id',
            'joinType' => 'INNER',
        ]);
    }

    /**
     * Returns a rules checker object that will be used for validating
     * application integrity.
     *
     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
     * @return \Cake\ORM\RulesChecker
     */
    // public function buildRules(RulesChecker $rules): RulesChecker
    // {
    //     $rules->add($rules->existsIn('banner_id', 'Banners'), ['errorField' => 'banner_id']);

    //     return $rules;
    // }
}
