Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I made these fix to be able to use the multiple attach file. #32

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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