統計
| ブランチ: | リビジョン:

pictcode / app / Model / Image.php @ dd7691f4

履歴 | 表示 | アノテート | ダウンロード (1.219 KB)

1 dd7691f4 root
<?php
2
App::uses('AppModel', 'Model');
3
/**
4
 * Image Model
5
 *
6
 */
7
class Image extends AppModel {
8
9
/**
10
 * Validation rules
11
 *
12
 * @var array
13
 */
14
        public $validate = array(
15
                'name' => array(
16
                        'notBlank' => array(
17
                                'rule' => array('notBlank'),
18
                                //'message' => 'Your custom message here',
19
                                //'allowEmpty' => false,
20
                                //'required' => false,
21
                                //'last' => false, // Stop validation after this rule
22
                                //'on' => 'create', // Limit validation to 'create' or 'update' operations
23
                        ),
24
                ),
25
        );
26
27
    public $actsAs = array(
28
        'UploadPack.Upload' => array(
29
                'image' => array(     //☆ここでは、"_file_name"を除いたカラム名を書く
30
                        'quality' => 95,   //☆画質指定、デフォルトでは75
31
                        'path' => ':webroot/upload/:model/:id/:hash.:extension',
32
                        'styles' => array(
33
                                'thumb' => '85x85'  //☆リサイズしたいサイズを書く
34
                        )
35
                )
36
        ),
37
        'Search.Searchable'
38
        );
39
40
        public $filterArgs = array(
41
                'name' => array('type' => 'query', 'method' => 'orConditions'),
42
                'status' => array('type' => 'value'),
43
        );
44
45
        public function orConditions( $data = array() ) {
46
                $filter = $data['name'];
47
                $cond = array(
48
                        'OR' => array(
49
                                $this->alias . '.name LIKE' => '%' . $filter . '%',
50
                        ),
51
                );
52
                return $cond;
53
        }
54
55
56
}