-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlugin.php
39 lines (35 loc) · 1.23 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php namespace Ribsousa\Featuredimages;
use System\Classes\PluginBase;
use RainLab\Blog\Controllers\Categories as CategoriesController;
use RainLab\Blog\Models\Category as CategoryModel;
class Plugin extends PluginBase
{
public $require = ['RainLab.Blog'];
public function pluginDetails()
{
return [
'name' => 'ribsousa.featuredimages::lang.plugin.name',
'description' => 'ribsousa.featuredimages::lang.plugin.description',
'author' => 'Ronaldo Ribeiro',
'icon' => 'icon-file'
];
}
public function boot()
{
CategoryModel::extend(function ($model) {
$model->attachMany['featured_images'] = [
'System\Models\File', 'order' => 'sort_order', 'delete' => true
];
});
CategoriesController::extendFormFields(function ($form, $model) {
if (!$model instanceof CategoryModel) return;
$form->addFields([
'featured_images' => [
'label' => 'ribsousa.featuredimages::lang.plugin.name',
'type' => 'fileupload',
'mode' => 'image',
]
]);
});
}
}