feat: implement admin user management interface and registration command

This commit is contained in:
Ümit Tunç
2026-04-28 21:41:20 +03:00
parent 7dfb13ffac
commit ae835c4c2f
5 changed files with 61 additions and 37 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class CreateAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create or reset admin user admin@citrus.com with a random password';
/**
* Execute the console command.
*/
public function handle()
{
$email = 'admin@citrus.com';
$password = Str::random(12);
$user = User::where('email', $email)->first();
if ($user) {
$user->password = Hash::make($password);
$user->level = 'Admin';
$user->save();
$status = 'updated';
} else {
$user = new User();
$user->name = 'Admin';
$user->email = $email;
$user->password = Hash::make($password);
$user->level = 'Admin';
$user->save();
$status = 'created';
}
$this->info("Admin user has been {$status}.");
$this->line("--------------------------------");
$this->info("Email: {$email}");
$this->info("Password: {$password}");
$this->line("--------------------------------");
return Command::SUCCESS;
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.1.1/exceljs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.2/FileSaver.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.0.0/jspdf.umd.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/devextreme-dist/23.1.5/css/<?php echo setting("DevExpress_Theme", false,"dx.light.compact") ?>">
<link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/23.1.5/css/<?php echo setting("DevExpress_Theme", false,"dx.light.compact") ?>.css">
<!-- Quill CSS -->
<link rel="stylesheet" href="https://cdn.quilljs.com/1.3.7/quill.snow.css">
+1
View File
@@ -21,6 +21,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'level',
];
/**
-21
View File
@@ -10,7 +10,6 @@
use App\Fields;
use App\User;
$teams = db("subcontractors")->get()->pluck("company_name_en")->toArray();
try{
$seviye = Contents::where("slug","user-level")->first();
$seviye = strip_tags($seviye->html);
@@ -214,12 +213,6 @@ columns : [
'name',
'name_ru',
'level',
{
dataField: 'subcontructer', // provides column values
lookup: {
dataSource: <?php echo json_encode_tr(db("subcontractors")->select("company_name_en")->get()->pluck("company_name_en")) ?>
}
},
'email',
'recover',
{
@@ -360,7 +353,6 @@ window.setTimeout(function() {
<tr>
<td>{{e2("ID")}}</td>
<td>{{e2("Name")}}</td>
<td>{{e2("Team")}}</td>
<td>{{e2("Level")}}</td>
<td>{{e2("E-Mail")}}</td>
<td>{{e2("Phone")}}</td>
@@ -379,19 +371,6 @@ window.setTimeout(function() {
<td>
<input type="text" name="name" value="{{$u->name}}" table="users" data-id="{{$u->id}}" class="name{{$u->id}} form-control edit" />
</td>
<td>
<select name="subcontructer" data-id="{{$u->id}}" class="form-control edit" table="users">
<option value="">{{e2("Select")}}</option>
<?php
foreach($teams AS $s) {
?>
<option value="{{$s}}" <?php if($u->subcontructer == $s) echo "selected"; ?>>{{$s}}</option>
<?php
}
?>
</select>
</td>
<td>
<select name="level"data-id="{{$u->id}}" table="users" class="form-control edit">
@if($seviye!=null)
@@ -1,7 +1,6 @@
{{col("col-12 detail","User Detail")}}
<?php
if(isAdmin()) {
$teams = db("subcontractors")->get()->pluck("company_name_en")->toArray();
if(getisset("update")) {
$post = $_POST;
$pic = upload("pic","profile_pic/");
@@ -78,20 +77,6 @@ if(isAdmin()) {
<label for="">{{e2("Name Ru")}}: </label><input type="text" value="" name="name_ru"
class="form-control">
</div>
<div class="col-md-6">
<label for="">{{e2("Team/Subconstructer")}}: </label>
<select name="subcontructer" id="" class="form-control">
<option value="">{{e2("Select")}}</option>
<?php
foreach($teams AS $s) {
?>
<option value="{{$s}}">{{$s}}</option>
<?php
}
?>
</select>
</div>
<div class="col-md-6">
<label for="">{{e2("Date of Birth")}}: </label><input type="date" value="" name="date_of_birth"
class="form-control">