Skip to content

Instantly share code, notes, and snippets.

View mariuswilms's full-sized avatar

Marius Wilms mariuswilms

View GitHub Profile
<?php
class Movie extends AppModel {
// ...
var $hasMany = array(
'Poster' => array(
'className' => 'Media.Attachment',
'foreignKey' => 'foreign_key',
'conditions' => array('Poster.model' => 'Movie', 'Poster.group' => 'poster'),
'dependent' => true,
),
<?php
class Movie extends AppModel {
// ...
var $hasMany = array(
'Attachment' => array(
'className' => 'Media.Attachment',
'foreignKey' => 'foreign_key',
'conditions' => array('Attachment.model' => 'Movie'),
'dependent' => true,
));
<?php
class Movie extends AppModel {
var $actsAs = array('Media.Transfer');
var $validate = array(
'file' => array(
'resource' => array('rule' => 'checkResource'),
'access' => array('rule' => 'checkAccess'),
'location' => array('rule' => array('checkLocation', array(MEDIA_TRANSFER, '/tmp/'))),
'permission' => array('rule' => array('checkPermission', '*')),