bookmarks /app/models/link_category.php

Language PHP Lines 35
MD5 Hash a3a0f8f41f6fa82a4b3e77961305302e
Repository https://github.com/hardsshah/bookmarks.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
class LinkCategory extends AppModel {

    var $name = 'LinkCategory';
    var $validate = array(
        'name' => array('notempty')
    );

    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $hasMany = array(
            'Link' => array('className' => 'Link',
                                'foreignKey' => 'link_category_id',
                                'dependent' => true,
                                'conditions' => '',
                                'fields' => '',
                                'order' => '',
                                'limit' => '',
                                'offset' => '',
                                'exclusive' => '',
                                'finderQuery' => '',
                                'counterQuery' => ''
        )
    );
    function beforeFind(&$queryData){
        $queryData['order'] = array('LinkCategory.name' => 'ASC');
    }
    function countLinks($categoryName){
        App::import('Model', 'Link');
        $link = new Link();
        $settings = array('conditions' => array('LinkCategory.name' => $categoryName));
        return $link->find('count', $settings);
    }

}
Back to Top