mirror of
https://github.com/JulienMalka/snowfield.git
synced 2025-06-08 18:09:06 +02:00
Added polr package
This commit is contained in:
parent
b53e3e0e34
commit
0d0b9592d4
9 changed files with 6994 additions and 0 deletions
88
packages/polr/createsuperuser.patch
Normal file
88
packages/polr/createsuperuser.patch
Normal file
|
@ -0,0 +1,88 @@
|
|||
diff --git a/app/Console/Commands/CreateSuperUser.php b/app/Console/Commands/CreateSuperUser.php
|
||||
new file mode 100755
|
||||
index 0000000..34a51a3
|
||||
--- /dev/null
|
||||
+++ b/app/Console/Commands/CreateSuperUser.php
|
||||
@@ -0,0 +1,68 @@
|
||||
+<?php
|
||||
+#/App/Console/Commands/CreateSuperUser.php
|
||||
+namespace App\Console\Commands;
|
||||
+
|
||||
+use Illuminate\Console\Command;
|
||||
+use App\Models\User;
|
||||
+use App\Helpers\UserHelper;
|
||||
+use App\Factories\UserFactory;
|
||||
+use Illuminate\Database\QueryException;
|
||||
+use Hash;
|
||||
+class CreateSuperUser extends Command
|
||||
+{
|
||||
+ /**
|
||||
+ * The name and signature of the console command.
|
||||
+ *
|
||||
+ * @var string
|
||||
+ */
|
||||
+ protected $signature = 'init:createsuperuser {pw}';
|
||||
+
|
||||
+ /**
|
||||
+ * The console command description.
|
||||
+ *
|
||||
+ * @var string
|
||||
+ */
|
||||
+ protected $description = 'Create a superuser';
|
||||
+
|
||||
+ /**
|
||||
+ * Create a new command instance.
|
||||
+ *
|
||||
+ * @return void
|
||||
+ */
|
||||
+ public function __construct()
|
||||
+ {
|
||||
+ parent::__construct();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Execute the console comman.
|
||||
+ *
|
||||
+ * @return mixed
|
||||
+ */
|
||||
+ public function handle()
|
||||
+
|
||||
+ {
|
||||
+ $pw = $this->argument('pw');
|
||||
+ try
|
||||
+ {
|
||||
+ if (UserHelper::userExists("admin"))
|
||||
+ {
|
||||
+ $user = UserHelper::getUserByUsername("admin");
|
||||
+ $user->password = Hash::make($pw);
|
||||
+ $user->save();
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ $user = UserFactory::createUser("admin", "admin@admin.fr", $pw, 1, "127.0.0.1", false, 0, UserHelper::$USER_ROLES['admin']);
|
||||
+ }
|
||||
+ }
|
||||
+ catch(QueryException $e)
|
||||
+ {
|
||||
+ if ($e->getCode() != 23000)
|
||||
+ {
|
||||
+ throw $e;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
|
||||
index 35aca72..753ba92 100644
|
||||
--- a/app/Console/Kernel.php
|
||||
+++ b/app/Console/Kernel.php
|
||||
@@ -13,7 +13,8 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
- \Torann\GeoIP\Console\Update::class
|
||||
+ \Torann\GeoIP\Console\Update::class,
|
||||
+ 'App\Console\Commands\CreateSuperUser'
|
||||
];
|
||||
|
||||
/**
|
Loading…
Add table
Add a link
Reference in a new issue