Blame view

src/Model/Table/OrganismesTable.php 1.24 KB
6c4edfa3   Alexandre   First Commit LabI...
1
2
3
<?php
namespace App\Model\Table;

6c4edfa3   Alexandre   First Commit LabI...
4
5
6
7
8
9
10
11
use Cake\ORM\Table;
use Cake\Validation\Validator;

/**
 * Organismes Model
 *
 * @property \Cake\ORM\Association\HasMany $Materiels
 */
0e5846aa   Alexandre   Css bouton valide...
12
class OrganismesTable extends AppTable
6c4edfa3   Alexandre   First Commit LabI...
13
14
15
16
17
{

    /**
     * Initialize method
     *
63c3cb16   epallier   Nombreux petits b...
18
19
     * @param array $config
     *            The configuration for the Table.
6c4edfa3   Alexandre   First Commit LabI...
20
21
22
23
24
     * @return void
     */
    public function initialize(array $config)
    {
        parent::initialize($config);
63c3cb16   epallier   Nombreux petits b...
25
        
6c4edfa3   Alexandre   First Commit LabI...
26
27
28
        $this->table('organismes');
        $this->displayField('id');
        $this->primaryKey('id');
63c3cb16   epallier   Nombreux petits b...
29
        
6c4edfa3   Alexandre   First Commit LabI...
30
31
32
33
34
35
36
37
        $this->hasMany('Materiels', [
            'foreignKey' => 'organisme_id'
        ]);
    }

    /**
     * Default validation rules.
     *
63c3cb16   epallier   Nombreux petits b...
38
39
     * @param \Cake\Validation\Validator $validator
     *            Validator instance.
6c4edfa3   Alexandre   First Commit LabI...
40
41
42
43
     * @return \Cake\Validation\Validator
     */
    public function validationDefault(Validator $validator)
    {
63c3cb16   epallier   Nombreux petits b...
44
45
46
47
48
49
50
51
52
53
        $validator->integer('id')->allowEmpty('id', 'create');
        
        $validator->allowEmpty('nom')->add('nom', 'valid', [
            'rule' => [
                'check_string'
            ],
            'message' => 'Le champ doit ĂȘtre valide.',
            'provider' => 'table'
        ]);
        
6c4edfa3   Alexandre   First Commit LabI...
54
55
56
        return $validator;
    }
}