How do I detect if new images have been uploaded to a gallery from the backend form, so I could manipulate them before saving.
I've tried the following, but it didn't work:
<?php namespace Author\Plugin\Models;
use Model;
class ModelName extends Model
{
public $attachMany = [
'gallery' => 'System\Models\File',
];
public function beforeSave()
{
if (Input::hasFile('gallery')) {
trace_log('new files');
} else {
trace_log('no new files');
}
}
}
-- it keeps giving me no new files message, regardless whether I upload new files or not.
You can use this code to resize image of your model
Its little tricky as it is using differed binding so.
if any doubt please comment.