Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Model/Behavior/UploadBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ public function setup(Model $model, $config = array()) {
* @return void
*/
protected function _setRelationModel(Model $model, $type) {
$type = Inflector::camelize($type);
$relation = 'hasOne';

//case is defined multiple is a hasMany
if ($this->isMultiple($model, $type)) {
$relation = 'hasMany';
}

$type = Inflector::camelize($type);

$model->{$relation}['Attachment' . $type] = array(
'className' => 'Attachment',
'foreignKey' => 'foreign_key',
Expand Down Expand Up @@ -537,6 +538,7 @@ public function saveAttachment(Model $model, $type, $filename, $originalName = n
'foreign_key' => $model->id,
'model' => $model->alias,
'type' => $type,
'filename LIKE' => '%' . strtolower(pathinfo($filename, PATHINFO_FILENAME)) . '%'
),
)
);
Expand Down