diff --git a/config/easy_panel_config.php b/config/easy_panel_config.php index c32ba29..06cddeb 100644 --- a/config/easy_panel_config.php +++ b/config/easy_panel_config.php @@ -1,5 +1,9 @@ \EasyPanel\Support\Auth\AdminIdentifier::class, + 'auth_class' => AdminIdentifier::class, // With this class you can manage how to create a admin or remove it. - 'admin_provider_class' => \EasyPanel\Support\User\UserProvider::class, + 'admin_provider_class' => UserProvider::class, //The namespace of lang manager class - 'lang_manager_class' => \EasyPanel\Services\LangService::class, + 'lang_manager_class' => LangService::class, // it's a place where a user if not authenticated will be redirected 'redirect_unauthorized' => '/', @@ -43,9 +47,9 @@ 'lazy_mode' => true, // database configure - 'database'=>[ - 'connection'=> env('EASY_PANEL_DB_CONNECTION'), - 'panel_admin_table'=>'panel_admins', - 'crud_table'=> 'cruds' + 'database' => [ + 'connection' => env('EASY_PANEL_DB_CONNECTION', env('DB_CONNECTION', 'mysql')), + 'panel_admin_table' => 'panel_admins', + 'crud_table' => 'cruds' ] ]; diff --git a/database/migrations/cruds_table.php b/database/migrations/cruds_table.php index 8d88072..8a750b7 100644 --- a/database/migrations/cruds_table.php +++ b/database/migrations/cruds_table.php @@ -11,7 +11,7 @@ class CreateCrudsTableEasypanel extends Migration */ public function getConnection() { - return config('easy_panel.database.connection') ?: config('database.default'); + return config('easy_panel.database.connection'); } /** diff --git a/database/migrations/panel_admins_table.php b/database/migrations/panel_admins_table.php index 4a5f5d2..6d043c3 100644 --- a/database/migrations/panel_admins_table.php +++ b/database/migrations/panel_admins_table.php @@ -11,8 +11,9 @@ class CreatePanelAdminsTableEasypanel extends Migration */ public function getConnection() { - return config('easy_panel.database.connection') ?: config('database.default'); + return config('easy_panel.database.connection'); } + /** * Run the migrations. * diff --git a/src/EasyPanelServiceProvider.php b/src/EasyPanelServiceProvider.php index 7166a12..ed5b21b 100644 --- a/src/EasyPanelServiceProvider.php +++ b/src/EasyPanelServiceProvider.php @@ -160,8 +160,7 @@ private function loadLivewireComponent() private function isDBConnected() { try { - $connection = config('easy_panel.database.connection') ?: config('database.default'); - DB::connection($connection)->getPDO(); + DB::connection(config('easy_panel.database.connection'))->getPDO(); } catch (Exception $e) { Log::error('Please check your DB connection \n Can not load routes of EasyPanel'); Log::error($e->getMessage()); diff --git a/src/Models/CRUD.php b/src/Models/CRUD.php index 7042929..ccb2c94 100644 --- a/src/Models/CRUD.php +++ b/src/Models/CRUD.php @@ -8,6 +8,8 @@ class CRUD extends Model { + protected $guarded = []; + /** * Create a new Eloquent model instance. * @@ -15,18 +17,13 @@ class CRUD extends Model */ public function __construct(array $attributes = []) { - $connection = config('easy_panel.database.connection') ?: config('database.default'); - $table = config('easy_panel.database.crud_table') ?: 'cruds'; - - $this->setConnection($connection); - - $this->setTable($table); + + $this->setConnection(config('easy_panel.database.connection')); + $this->setTable(config('easy_panel.database.crud_table')); parent::__construct($attributes); } - protected $guarded = []; - public function scopeActive($query) { return $query->where('built', true)->where('active', true)->get(); diff --git a/src/Models/PanelAdmin.php b/src/Models/PanelAdmin.php index 33fe9cb..afa37bb 100644 --- a/src/Models/PanelAdmin.php +++ b/src/Models/PanelAdmin.php @@ -9,25 +9,22 @@ class PanelAdmin extends Model { + protected $guarded = []; + /** - * Create a new Eloquent model instance. - * - * @param array $attributes - */ + * Create a new Eloquent model instance. + * + * @param array $attributes + */ public function __construct(array $attributes = []) { - $connection = config('easy_panel.database.connection') ?: config('database.default'); - $table = config('easy_panel.database.panel_admin_table') ?: 'panel_admins'; - - $this->setConnection($connection); - $this->setTable($table); + $this->setConnection(config('easy_panel.database.connection')); + $this->setTable(config('easy_panel.database.panel_admin_table')); parent::__construct($attributes); } - protected $guarded = []; - public function user() { return $this->belongsTo(config('easy_panel.user_model'));