Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
24 / 24 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ModelsImagesTable | |
100.00% |
24 / 24 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| initialize | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| validationDefault | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
| buildRules | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | |
| 4 | namespace App\Model\Table; |
| 5 | |
| 6 | use Cake\ORM\RulesChecker; |
| 7 | use Cake\ORM\Table; |
| 8 | use Cake\Validation\Validator; |
| 9 | |
| 10 | /** |
| 11 | * ModelsImages Model |
| 12 | * |
| 13 | * @property \App\Model\Table\ImagesTable&\Cake\ORM\Association\BelongsTo $Images |
| 14 | * @method \App\Model\Entity\ModelsImage newEmptyEntity() |
| 15 | * @method \App\Model\Entity\ModelsImage newEntity(array $data, array $options = []) |
| 16 | * @method array<\App\Model\Entity\ModelsImage> newEntities(array $data, array $options = []) |
| 17 | * @method \App\Model\Entity\ModelsImage get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) |
| 18 | * @method \App\Model\Entity\ModelsImage findOrCreate($search, ?callable $callback = null, array $options = []) |
| 19 | * @method \App\Model\Entity\ModelsImage patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) |
| 20 | * @method array<\App\Model\Entity\ModelsImage> patchEntities(iterable $entities, array $data, array $options = []) |
| 21 | * @method \App\Model\Entity\ModelsImage|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) |
| 22 | * @method \App\Model\Entity\ModelsImage saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) |
| 23 | * @method iterable<\App\Model\Entity\ModelsImage>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\ModelsImage>|false saveMany(iterable $entities, array $options = []) |
| 24 | * @method iterable<\App\Model\Entity\ModelsImage>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\ModelsImage> saveManyOrFail(iterable $entities, array $options = []) |
| 25 | * @method iterable<\App\Model\Entity\ModelsImage>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\ModelsImage>|false deleteMany(iterable $entities, array $options = []) |
| 26 | * @method iterable<\App\Model\Entity\ModelsImage>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\ModelsImage> deleteManyOrFail(iterable $entities, array $options = []) |
| 27 | * @mixin \Cake\ORM\Behavior\TimestampBehavior |
| 28 | */ |
| 29 | class ModelsImagesTable extends Table |
| 30 | { |
| 31 | /** |
| 32 | * Initialize method |
| 33 | * |
| 34 | * @param array<string, mixed> $config The configuration for the Table. |
| 35 | * @return void |
| 36 | */ |
| 37 | public function initialize(array $config): void |
| 38 | { |
| 39 | parent::initialize($config); |
| 40 | |
| 41 | $this->setTable('models_images'); |
| 42 | $this->setDisplayField('id'); |
| 43 | $this->setPrimaryKey('id'); |
| 44 | |
| 45 | $this->addBehavior('Timestamp'); |
| 46 | |
| 47 | $this->belongsTo('Images', [ |
| 48 | 'foreignKey' => 'image_id', |
| 49 | 'joinType' => 'INNER', |
| 50 | ]); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Default validation rules. |
| 55 | * |
| 56 | * @param \Cake\Validation\Validator $validator Validator instance. |
| 57 | * @return \Cake\Validation\Validator |
| 58 | */ |
| 59 | public function validationDefault(Validator $validator): Validator |
| 60 | { |
| 61 | $validator |
| 62 | ->scalar('model') |
| 63 | ->maxLength('model', 255) |
| 64 | ->requirePresence('model', 'create') |
| 65 | ->notEmptyString('model'); |
| 66 | |
| 67 | $validator |
| 68 | ->uuid('foreign_key') |
| 69 | ->requirePresence('foreign_key', 'create') |
| 70 | ->notEmptyString('foreign_key'); |
| 71 | |
| 72 | $validator |
| 73 | ->uuid('image_id') |
| 74 | ->notEmptyString('image_id'); |
| 75 | |
| 76 | return $validator; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Returns a rules checker object that will be used for validating |
| 81 | * application integrity. |
| 82 | * |
| 83 | * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. |
| 84 | * @return \Cake\ORM\RulesChecker |
| 85 | */ |
| 86 | public function buildRules(RulesChecker $rules): RulesChecker |
| 87 | { |
| 88 | $rules->add($rules->existsIn(['image_id'], 'Images'), ['errorField' => 'image_id']); |
| 89 | |
| 90 | return $rules; |
| 91 | } |
| 92 | } |