new kernel, ms bearer
This commit is contained in:
@ -7,5 +7,5 @@
|
||||
"module_class": "kernel\\modules\\user\\UserModule",
|
||||
"module_class_file": "{KERNEL_MODULES}/user/UserModule.php",
|
||||
"routs": "routs/user.php",
|
||||
"dependence": "menu"
|
||||
"dependence": "menu,secure"
|
||||
}
|
@ -19,6 +19,8 @@ return new class extends Migration
|
||||
$table->string('email', 255);
|
||||
$table->string('password_hash', 255);
|
||||
$table->integer('role')->default(1);
|
||||
$table->string('access_token', 255)->nullable(true);
|
||||
$table->dateTime('access_token_expires_at')->nullable(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string $username
|
||||
* @property string $email
|
||||
* @property string $password_hash
|
||||
* @property string $access_token
|
||||
* @property string $access_token_expires_at
|
||||
* @method static find($id)
|
||||
*/
|
||||
class User extends Model {
|
||||
@ -15,7 +17,7 @@ class User extends Model {
|
||||
const ADMIN_USER_ROLE = 9;
|
||||
|
||||
protected $table = 'user';
|
||||
protected $fillable = ['username', 'email', 'password_hash', 'role'];
|
||||
protected $fillable = ['username', 'email', 'password_hash', 'role', 'access_token', 'access_token_expires_at'];
|
||||
protected array $dates = ['deleted at'];
|
||||
|
||||
public static function labels(): array
|
||||
@ -24,7 +26,7 @@ class User extends Model {
|
||||
'username' => 'Логин',
|
||||
'email' => 'Email',
|
||||
'created_at' => 'Создан',
|
||||
'updated_at' => 'Обновлен'
|
||||
'updated_at' => 'Обновлен',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,16 @@ use Phroute\Phroute\RouteCollector;
|
||||
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->group(["prefix" => "user"], callback: function (RouteCollector $router){
|
||||
App::$collector->get('/', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||
App::$collector->get('/create', [\kernel\modules\user\controllers\UserController::class, 'actionCreate']);
|
||||
App::$collector->post("/", [\kernel\modules\user\controllers\UserController::class, 'actionAdd']);
|
||||
App::$collector->get('/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionView']);
|
||||
App::$collector->any('/update/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionUpdate']);
|
||||
App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']);
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "user"], callback: function (RouteCollector $router) {
|
||||
App::$collector->get('/', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||
App::$collector->get('/create', [\kernel\modules\user\controllers\UserController::class, 'actionCreate']);
|
||||
App::$collector->post("/", [\kernel\modules\user\controllers\UserController::class, 'actionAdd']);
|
||||
App::$collector->get('/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionView']);
|
||||
App::$collector->any('/update/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionUpdate']);
|
||||
App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
});
|
@ -33,6 +33,11 @@ class UserService
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByField(string $field, string $value)
|
||||
{
|
||||
return User::where($field, $value)->first();
|
||||
@ -72,4 +77,9 @@ class UserService
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getByAccessToken(string $token)
|
||||
{
|
||||
return $this->getByField("access_token", $token);
|
||||
}
|
||||
|
||||
}
|
16
kernel/modules/user/table/columns/UserDeleteActionColumn.php
Normal file
16
kernel/modules/user/table/columns/UserDeleteActionColumn.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\user\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class UserDeleteActionColumn extends ActionColumn
|
||||
{
|
||||
protected string $prefix = "/delete/";
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-danger'>Удалить</a> ";
|
||||
}
|
||||
}
|
16
kernel/modules/user/table/columns/UserEditActionColumn.php
Normal file
16
kernel/modules/user/table/columns/UserEditActionColumn.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\user\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class UserEditActionColumn extends ActionColumn
|
||||
{
|
||||
protected string $prefix = "/update/";
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-success'>Редактировать</a> ";
|
||||
}
|
||||
}
|
16
kernel/modules/user/table/columns/UserViewActionColumn.php
Normal file
16
kernel/modules/user/table/columns/UserViewActionColumn.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\user\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class UserViewActionColumn extends ActionColumn
|
||||
{
|
||||
protected string $prefix = "/";
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-primary'>Просмотр</a> ";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user