FEATURE: prepare handlers for categories
This commit is contained in:
+15
-7
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Handlers\Contracts\AppHandler;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
@@ -17,7 +18,9 @@ class Module extends Model
|
||||
'description',
|
||||
'alias',
|
||||
'module_settings',
|
||||
'enabled'
|
||||
'enabled',
|
||||
'support_categories',
|
||||
'manages_content'
|
||||
];
|
||||
protected $guarded = [];
|
||||
|
||||
@@ -40,14 +43,19 @@ class Module extends Model
|
||||
throw new \ErrorException('Modules can be installed only via Artisan!');
|
||||
}
|
||||
|
||||
$managesContent = $handler instanceof AppHandler;
|
||||
$supportCategories = $managesContent ? call_user_func([$handler, 'supportCategories']) : false;
|
||||
|
||||
// insert module into database
|
||||
$module = Module::create([
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'handler' => $handler,
|
||||
'alias' => $alias,
|
||||
'module_settings' => json_encode($settings),
|
||||
'enabled' => 1
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'handler' => $handler,
|
||||
'manages_content' => $managesContent,
|
||||
'support_categories' => $supportCategories,
|
||||
'alias' => $alias,
|
||||
'module_settings' => json_encode($settings),
|
||||
'enabled' => 1
|
||||
]);
|
||||
|
||||
// install something module-specific
|
||||
|
||||
Reference in New Issue
Block a user