kharanenka / oc-data-file-model
Trait helps to get attached to the model file data
Installs: 31 610
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2024-11-29 05:20:47 UTC
README
Trait helps to get attached to the model file data. For 'attache one' relation returns data array with fields:
- (string) full_path
- (string) path
- (string) title
- (string) alt
For 'attache many' relation returns array with files data.
#Installation
Require this package in your composer.json
and update composer.
"kharanenka/oc-data-file-model": "1.*"
#Uses
class MyModel extends Model { use DataFileModel; public $attachOne = ['preview_image' => 'System\Models\File']; public $attachMany = ['images' => 'System\Models\File']; } $obModel = MyModel::first(); $arFileData = $obModel->getFileData('preview_image'); $arFileList = $obModel->getFileListData('images');
Result:
$arFileData = [ 'full_path' => '...', 'path' => '...', 'title' => '...', 'alt' => '...', ]; $arFileList = [ [ 'full_path' => '...', 'path' => '...', 'title' => '...', 'alt' => '...', ],[ 'full_path' => '...', 'path' => '...', 'title' => '...', 'alt' => '...', ], ];