first
This commit is contained in:
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile_relationship;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use itguild\forms\builders\SelectBuilder;
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||||
use kernel\app_modules\gestalt_profile_relationship\services\GestaltProfileRelationshipService;
|
||||
use kernel\app_modules\tag\models\Tag;
|
||||
use kernel\app_modules\tag\service\TagEntityService;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\modules\option\service\OptionService;
|
||||
use kernel\Request;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
class Gestalt_profile_relationshipModule extends Module
|
||||
{
|
||||
|
||||
public MenuService $menuService;
|
||||
|
||||
public MigrationService $migrationService;
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuService = new MenuService();
|
||||
$this->migrationService = new MigrationService();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/gestalt_profile_relationship/migrations");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Профили психологов (связь)",
|
||||
"url" => "/admin/gestalt_profile_relationship",
|
||||
"slug" => "gestalt_profile_relationship",
|
||||
]);
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Профили психологов",
|
||||
"url" => "/admin/settings/gestalt_profile_relationship",
|
||||
"slug" => "gestalt_profile_relationship_settings",
|
||||
"parent_slug" => "settings"
|
||||
]);
|
||||
|
||||
OptionService::createFromParams("entity_gestalt_profile_relationship_list", "{}", "Список тегов");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("gestalt_profile_relationship");
|
||||
$this->menuService->removeItemBySlug("gestalt_profile_relationship_settings");
|
||||
$this->migrationService->rollbackAtPath("{KERNEL_APP_MODULES}/gestalt_profile_relationship/migrations");
|
||||
OptionService::removeOptionByKey("entity_gestalt_profile_relationship_list");
|
||||
}
|
||||
|
||||
public function formInputs(string $entity, Model $model = null): void
|
||||
{
|
||||
if (isset($model->id)) {
|
||||
$value = GestaltProfileRelationshipService::getProfileByEntity($entity, $model->id);
|
||||
}
|
||||
|
||||
$input = SelectBuilder::build("gestalt_profiles[]", [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'Психологи',
|
||||
'value' => $value ?? '',
|
||||
'multiple' => "multiple",
|
||||
'options' => GestaltProfileRelationshipService::getProfilesList()
|
||||
]);
|
||||
$input->setLabel("Психологи");
|
||||
$input->create()->render();
|
||||
}
|
||||
|
||||
public function saveInputs(string $entity, Model $model, Request $request): void
|
||||
{
|
||||
GestaltProfileRelationship::where("entity", $entity)->where("entity_id", $model->id)->delete();
|
||||
|
||||
$profiles = $request->post("gestalt_profiles");
|
||||
if (is_array($profiles)) {
|
||||
foreach ($profiles as $profile) {
|
||||
$gpr = new GestaltProfileRelationship();
|
||||
$gpr->entity = $entity;
|
||||
$gpr->entity_id = $model->id;
|
||||
$gpr->gestalt_profile_id = $profile;
|
||||
$gpr->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getItems(string $entity, Model $model): array|string
|
||||
{
|
||||
$profiles = GestaltProfileRelationship::where("entity", $entity)->where("entity_id", $model->id)->with("profile")->get();
|
||||
return $profiles->pluck('profile.fio')->filter()->implode(', ');
|
||||
}
|
||||
|
||||
public function getItem(string $entity, string $entity_id): string
|
||||
{
|
||||
$profiles = GestaltProfileRelationship::where("entity", $entity)->where("entity_id", $entity_id)->with("profile")->get();
|
||||
return $profiles->pluck('profile.fio')->filter()->implode(', ');
|
||||
}
|
||||
|
||||
public function getItemsObject(string $entity, string $entity_id)
|
||||
{
|
||||
return GestaltProfileRelationship::where("entity", $entity)->where("entity_id", $entity_id)->with("profile")->get();
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile_relationship\controllers;
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use kernel\AdminController;
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\forms\CreateGestaltProfileRelationshipForm;
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||||
use kernel\app_modules\gestalt_profile_relationship\services\GestaltProfileRelationshipService;
|
||||
use kernel\EntityRelation;
|
||||
use kernel\Flash;
|
||||
use kernel\Request;
|
||||
|
||||
class GestaltProfileRelationshipController extends AdminController
|
||||
{
|
||||
private GestaltProfileRelationshipService $gestalt_profile_relationshipService;
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = KERNEL_APP_MODULES_DIR . "/gestalt_profile_relationship/views/";
|
||||
$this->gestalt_profile_relationshipService = new GestaltProfileRelationshipService();
|
||||
}
|
||||
|
||||
public function actionCreate(): void
|
||||
{
|
||||
$this->cgView->render("form.php");
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionAdd(): void
|
||||
{
|
||||
$gestalt_profile_relationshipForm = new CreateGestaltProfileRelationshipForm();
|
||||
$gestalt_profile_relationshipForm->load($_REQUEST);
|
||||
if ($gestalt_profile_relationshipForm->validate()){
|
||||
$gestalt_profile_relationship = $this->gestalt_profile_relationshipService->create($gestalt_profile_relationshipForm);
|
||||
if ($gestalt_profile_relationship){
|
||||
$this->redirect("/admin/gestalt_profile_relationship/view/" . $gestalt_profile_relationship->id);
|
||||
}
|
||||
}
|
||||
$this->redirect("/admin/gestalt_profile_relationship/create");
|
||||
}
|
||||
|
||||
public function actionIndex($page_number = 1): void
|
||||
{
|
||||
$this->cgView->render("index.php", ['page_number' => $page_number]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionView($id): void
|
||||
{
|
||||
$gestalt_profile_relationship = GestaltProfileRelationship::find($id);
|
||||
|
||||
if (!$gestalt_profile_relationship){
|
||||
throw new Exception(message: "The gestalt_profile_relationship not found");
|
||||
}
|
||||
$this->cgView->render("view.php", ['gestalt_profile_relationship' => $gestalt_profile_relationship]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionUpdate($id): void
|
||||
{
|
||||
$model = GestaltProfileRelationship::find($id);
|
||||
if (!$model){
|
||||
throw new Exception(message: "The gestalt_profile_relationship not found");
|
||||
}
|
||||
|
||||
$this->cgView->render("form.php", ['model' => $model]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionEdit($id): void
|
||||
{
|
||||
$gestalt_profile_relationship = GestaltProfileRelationship::find($id);
|
||||
if (!$gestalt_profile_relationship){
|
||||
throw new Exception(message: "The gestalt_profile_relationship not found");
|
||||
}
|
||||
$gestalt_profile_relationshipForm = new CreateGestaltProfileRelationshipForm();
|
||||
$gestalt_profile_relationshipService = new GestaltProfileRelationshipService();
|
||||
$gestalt_profile_relationshipForm->load($_REQUEST);
|
||||
if ($gestalt_profile_relationshipForm->validate()) {
|
||||
$gestalt_profile_relationship = $gestalt_profile_relationshipService->update($gestalt_profile_relationshipForm, $gestalt_profile_relationship);
|
||||
if ($gestalt_profile_relationship) {
|
||||
$this->redirect("/admin/gestalt_profile_relationship/view/" . $gestalt_profile_relationship->id);
|
||||
}
|
||||
}
|
||||
$this->redirect("/admin/gestalt_profile_relationship/update/" . $id);
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionDelete($id): void
|
||||
{
|
||||
$gestalt_profile_relationship = GestaltProfileRelationship::find($id)->first();
|
||||
$gestalt_profile_relationship->delete();
|
||||
$this->redirect("/admin/gestalt_profile_relationship/");
|
||||
}
|
||||
|
||||
public function actionSettings(): void
|
||||
{
|
||||
$this->cgView->render('settingsForm.php');
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionSaveSettings(): void
|
||||
{
|
||||
$request = new Request();
|
||||
$entities = $request->post('entity');
|
||||
EntityRelation::configurationEntitiesByProperty($entities, 'gestalt_profile_relationship');
|
||||
|
||||
Flash::setMessage("success", "Настройка прошла успешно");
|
||||
$this->redirect("/admin/settings/gestalt_profile_relationship", 302);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
\kernel\App::$db->schema->create('gestalt_profile_relationship', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('gestalt_profile_id')->nullable(false);
|
||||
$table->string('entity', 255)->nullable(false);
|
||||
$table->integer('entity_id')->nullable(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
\kernel\App::$db->schema->dropIfExists('gestalt_profile_relationship');
|
||||
}
|
||||
};
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile_relationship\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
|
||||
// Добавить @property
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $gestalt_profile_id
|
||||
* @property int $entity_id
|
||||
* @property string $entity
|
||||
*/
|
||||
class GestaltProfileRelationship extends Model
|
||||
{
|
||||
const DISABLE_STATUS = 0;
|
||||
const ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = 'gestalt_profile_relationship';
|
||||
|
||||
protected $fillable = ['gestalt_profile_id', 'entity', 'entity_id'];
|
||||
|
||||
public static function labels(): array
|
||||
{
|
||||
// Заполнить массив
|
||||
// Пример: [
|
||||
// 'label' => 'Заголовок',
|
||||
// 'entity' => 'Сущность',
|
||||
// 'slug' => 'Slug',
|
||||
// 'status' => 'Статус',
|
||||
// ]
|
||||
|
||||
return [
|
||||
'gestalt_profile_id' => 'Профиль',
|
||||
'entity' => 'Сущность',
|
||||
'entity_id' => 'ID сущности',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getStatus(): array
|
||||
{
|
||||
return [
|
||||
self::DISABLE_STATUS => "Не активный",
|
||||
self::ACTIVE_STATUS => "Активный",
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Gestalt_profile::class, 'gestalt_profile_id');
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile_relationship\models\forms;
|
||||
|
||||
use kernel\FormModel;
|
||||
|
||||
class CreateGestaltProfileRelationshipForm extends FormModel
|
||||
{
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
// Заполнить массив правил
|
||||
// Пример:
|
||||
// return [
|
||||
// 'label' => 'required|min-str-len:5|max-str-len:30',
|
||||
// 'entity' => 'required',
|
||||
// 'slug' => '',
|
||||
// 'status' => ''
|
||||
// ];
|
||||
return [
|
||||
'gestalt_profile_id' => 'required|integer',
|
||||
'entity' => 'required|min-str-len:5|max-str-len:30',
|
||||
'entity_id' => 'required|integer',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use kernel\App;
|
||||
use kernel\CgRouteCollector;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (CgRouteCollector $router) {
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "gestalt_profile_relationship"], function (CGRouteCollector $router) {
|
||||
App::$collector->get('/', [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionIndex']);
|
||||
App::$collector->get('/create', [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionCreate']);
|
||||
App::$collector->post("/", [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionAdd']);
|
||||
App::$collector->get('/view/{id}', [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionView']);
|
||||
App::$collector->any('/update/{id}', [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionUpdate']);
|
||||
App::$collector->any("/edit/{id}", [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\app\modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionDelete']);
|
||||
});
|
||||
App::$collector->group(["prefix" => "settings"], function (CGRouteCollector $router) {
|
||||
App::$collector->get('/gestalt_profile_relationship', [\kernel\app_modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionSettings']);
|
||||
App::$collector->post('/gestalt_profile_relationship/update', [\kernel\app_modules\gestalt_profile_relationship\controllers\GestaltProfileRelationshipController::class, 'actionSaveSettings']);
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile_relationship\services;
|
||||
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||||
use kernel\FormModel;
|
||||
|
||||
class GestaltProfileRelationshipService
|
||||
{
|
||||
public function create(FormModel $form_model): false|GestaltProfileRelationship
|
||||
{
|
||||
$model = new GestaltProfileRelationship();
|
||||
$model->gestalt_profile_id = $form_model->getItem('gestalt_profile_id');
|
||||
$model->entity = $form_model->getItem('entity');
|
||||
$model->entity_id = $form_model->getItem('entity_id');
|
||||
|
||||
if ($model->save()){
|
||||
return $model;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update(FormModel $form_model, GestaltProfileRelationship $gestalt_profile_relationship): false|GestaltProfileRelationship
|
||||
{
|
||||
$gestalt_profile_relationship->gestalt_profile_id = $form_model->getItem('gestalt_profile_id');
|
||||
$gestalt_profile_relationship->entity = $form_model->getItem('entity');
|
||||
$gestalt_profile_relationship->entity_id = $form_model->getItem('entity_id');
|
||||
|
||||
if ($gestalt_profile_relationship->save()){
|
||||
return $gestalt_profile_relationship;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getProfileByEntity(string $entity, int $entity_id): array
|
||||
{
|
||||
$profiles = GestaltProfileRelationship::with('profile')->where("entity_id", $entity_id)->where("entity", $entity)->get();
|
||||
$value = [];
|
||||
foreach ($profiles as $profile) {
|
||||
$value[$profile->gestalt_profile_id] = $profile->profile->fio;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public static function getProfilesList(): array
|
||||
{
|
||||
return Gestalt_profile::pluck('fio', 'id')->all();
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @var GestaltProfileRelationship $model
|
||||
*/
|
||||
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/gestalt_profile_relationship/edit/" . $model->id : "/admin/gestalt_profile_relationship", 'multipart/form-data');
|
||||
|
||||
// Пример формы:
|
||||
|
||||
/*
|
||||
$form->field(\itguild\forms\inputs\TextInput::class, 'title', [
|
||||
'class' => "form-control",
|
||||
'placeholder' => 'Заголовок поста',
|
||||
'value' => $model->title ?? ''
|
||||
])
|
||||
->setLabel("Заголовок")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\Select::class, name: "user_id", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->user_id ?? ''
|
||||
])
|
||||
->setLabel("Пользователи")
|
||||
->setOptions(\kernel\modules\user\service\UserService::createUsernameArr())
|
||||
->render();
|
||||
*/
|
||||
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
|
||||
'class' => "btn btn-primary ",
|
||||
'value' => 'Отправить',
|
||||
'typeInput' => 'submit'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
|
||||
'class' => "btn btn-warning",
|
||||
'value' => 'Сбросить',
|
||||
'typeInput' => 'reset'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$form->endForm();
|
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $gestalt_profile_relationship
|
||||
* @var int $page_number
|
||||
* @var \kernel\CgView $view
|
||||
*/
|
||||
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
use kernel\widgets\IconBtn\IconBtnCreateWidget;
|
||||
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
||||
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
||||
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
||||
|
||||
$view->setTitle("Список gestalt_profile_relationship");
|
||||
$view->setMeta([
|
||||
'description' => 'Список gestalt_profile_relationship системы'
|
||||
]);
|
||||
|
||||
//Для использования таблицы с моделью, необходимо создать таблицу в базе данных
|
||||
$table = new ListEloquentTable(new EloquentDataProvider(GestaltProfileRelationship::class, [
|
||||
'currentPage' => $page_number,
|
||||
'perPage' => 8,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/gestalt_profile_relationship"
|
||||
]));
|
||||
|
||||
|
||||
//$table = new \Itguild\Tables\ListJsonTable(json_encode(
|
||||
// [
|
||||
// 'meta' => [
|
||||
// 'total' => 0,
|
||||
// 'totalWithFilters' => 0,
|
||||
// 'columns' => [
|
||||
// 'title',
|
||||
// 'slug',
|
||||
// 'status',
|
||||
// ],
|
||||
// 'perPage' => 5,
|
||||
// 'currentPage' => 1,
|
||||
// 'baseUrl' => '/admin/some',
|
||||
// 'params' => [
|
||||
// 'class' => 'table table-bordered',
|
||||
// 'border' => 2
|
||||
// ]
|
||||
// ],
|
||||
// 'filters' => [],
|
||||
// 'data' => [],
|
||||
// ]
|
||||
//));
|
||||
|
||||
// Пример фильтра
|
||||
$table->columns([
|
||||
'gestalt_profile_id' => [
|
||||
'value' => function ($data) {
|
||||
return \kernel\app_modules\gestalt_profile\models\Gestalt_profile::find($data)->fio ?? '';
|
||||
}
|
||||
],
|
||||
]);
|
||||
|
||||
//$table->beforePrint(function () {
|
||||
// return IconBtnCreateWidget::create(['url' => '/admin/gestalt_profile_relationship/create'])->run();
|
||||
//});
|
||||
|
||||
$table->addAction(function($row) {
|
||||
return IconBtnViewWidget::create(['url' => '/admin/gestalt_profile_relationship/view/' . $row['id']])->run();
|
||||
});
|
||||
//$table->addAction(function($row) {
|
||||
// return IconBtnEditWidget::create(['url' => '/admin/gestalt_profile_relationship/update/' . $row['id']])->run();
|
||||
//});
|
||||
$table->addAction(function($row) {
|
||||
return IconBtnDeleteWidget::create(['url' => '/admin/gestalt_profile_relationship/delete/' . $row['id']])->run();
|
||||
});
|
||||
$table->create();
|
||||
$table->render();
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm("/admin/settings/gestalt_profile_relationship/update");
|
||||
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<h5>Выберите сущности, к которым хотите прикрепить фото</h5>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$form->field(\itguild\forms\inputs\Select::class, "entity[]", [
|
||||
'class' => "form-control",
|
||||
'value' => \kernel\EntityRelation::getEntityByProperty('gestalt_profile_relationship') ?? '',
|
||||
'multiple' => "multiple",
|
||||
|
||||
])
|
||||
->setLabel("Сущности")
|
||||
->setOptions(\kernel\EntityRelation::getEntityList())
|
||||
->render();
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
|
||||
'class' => "btn btn-primary ",
|
||||
'value' => 'Отправить',
|
||||
'typeInput' => 'submit'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
|
||||
'class' => "btn btn-warning",
|
||||
'value' => 'Сбросить',
|
||||
'typeInput' => 'reset'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$form->endForm();
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $gestalt_profile_relationship
|
||||
*/
|
||||
|
||||
use Itguild\EloquentTable\ViewEloquentTable;
|
||||
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
|
||||
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
||||
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
||||
use kernel\widgets\IconBtn\IconBtnListWidget;
|
||||
|
||||
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($gestalt_profile_relationship, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/gestalt_profile_relationship",
|
||||
]));
|
||||
$table->beforePrint(function () use ($gestalt_profile_relationship) {
|
||||
$btn = IconBtnListWidget::create(['url' => '/admin/gestalt_profile_relationship'])->run();
|
||||
// $btn .= IconBtnEditWidget::create(['url' => '/admin/gestalt_profile_relationship/update/' . $gestalt_profile_relationship->id])->run();
|
||||
$btn .= IconBtnDeleteWidget::create(['url' => '/admin/gestalt_profile_relationship/delete/' . $gestalt_profile_relationship->id])->run();
|
||||
return $btn;
|
||||
});
|
||||
|
||||
$table->rows([
|
||||
'gestalt_profile_id' => [
|
||||
'value' => function ($data) {
|
||||
return \kernel\app_modules\gestalt_profile\models\Gestalt_profile::find($data)->fio ?? '';
|
||||
}
|
||||
],
|
||||
]);
|
||||
|
||||
$table->create();
|
||||
$table->render();
|
Reference in New Issue
Block a user