first
This commit is contained in:
43
kernel/app_modules/gestalt_profile/Gestalt_profileModule.php
Normal file
43
kernel/app_modules/gestalt_profile/Gestalt_profileModule.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile;
|
||||
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
class Gestalt_profileModule 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/migrations");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Профили психологов",
|
||||
"url" => "/admin/gestalt_profile",
|
||||
"slug" => "gestalt_profile",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->migrationService->rollbackAtPath("{KERNEL_APP_MODULES}/gestalt_profile/migrations");
|
||||
$this->menuService->removeItemBySlug("gestalt_profile");
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile\controllers;
|
||||
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
use kernel\modules\post\models\Post;
|
||||
use kernel\RestController;
|
||||
|
||||
class GestaltProfileRestController extends RestController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new Gestalt_profile();
|
||||
}
|
||||
|
||||
protected function expand(): array
|
||||
{
|
||||
return ["user"];
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile\controllers;
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use kernel\AdminController;
|
||||
use kernel\app_modules\gestalt_profile\models\forms\CreateGestalt_profileForm;
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
use kernel\app_modules\gestalt_profile\services\Gestalt_profileService;
|
||||
use kernel\helpers\Debug;
|
||||
|
||||
class Gestalt_profileController extends AdminController
|
||||
{
|
||||
private Gestalt_profileService $gestalt_profileService;
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = KERNEL_APP_MODULES_DIR . "/gestalt_profile/views/";
|
||||
$this->gestalt_profileService = new Gestalt_profileService();
|
||||
}
|
||||
|
||||
public function actionCreate(): void
|
||||
{
|
||||
$this->cgView->render("form.php");
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionAdd(): void
|
||||
{
|
||||
$gestalt_profileForm = new CreateGestalt_profileForm();
|
||||
$gestalt_profileForm->load($_REQUEST);
|
||||
if ($gestalt_profileForm->validate()){
|
||||
$gestalt_profile = $this->gestalt_profileService->create($gestalt_profileForm);
|
||||
if ($gestalt_profile){
|
||||
$this->redirect("/admin/gestalt_profile/view/" . $gestalt_profile->id);
|
||||
}
|
||||
}
|
||||
$this->redirect("/admin/gestalt_profile/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 = Gestalt_profile::find($id);
|
||||
|
||||
if (!$gestalt_profile){
|
||||
throw new Exception(message: "The gestalt_profile not found");
|
||||
}
|
||||
$this->cgView->render("view.php", ['gestalt_profile' => $gestalt_profile]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionUpdate($id): void
|
||||
{
|
||||
$model = Gestalt_profile::find($id);
|
||||
if (!$model){
|
||||
throw new Exception(message: "The gestalt_profile not found");
|
||||
}
|
||||
|
||||
$this->cgView->render("form.php", ['model' => $model]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionEdit($id): void
|
||||
{
|
||||
$gestalt_profile = Gestalt_profile::find($id);
|
||||
if (!$gestalt_profile){
|
||||
throw new Exception(message: "The gestalt_profile not found");
|
||||
}
|
||||
$gestalt_profileForm = new CreateGestalt_profileForm();
|
||||
$gestalt_profileService = new Gestalt_profileService();
|
||||
$gestalt_profileForm->load($gestalt_profile->toArray());
|
||||
$gestalt_profileForm->load($_REQUEST);
|
||||
if ($gestalt_profileForm->validate()) {
|
||||
$gestalt_profile = $gestalt_profileService->update($gestalt_profileForm, $gestalt_profile);
|
||||
if ($gestalt_profile) {
|
||||
$this->redirect("/admin/gestalt_profile/view/" . $gestalt_profile->id);
|
||||
}
|
||||
}
|
||||
$this->redirect("/admin/gestalt_profile/update/" . $id);
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionDelete($id): void
|
||||
{
|
||||
$gestalt_profile = Gestalt_profile::find($id)->first();
|
||||
$gestalt_profile->delete();
|
||||
$this->redirect("/admin/gestalt_profile/");
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?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', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('fio', 255)->nullable(false);
|
||||
$table->string('phone', 255)->nullable(false);
|
||||
$table->string('email', 255)->nullable(false);
|
||||
$table->string('city', 255);
|
||||
$table->string('photo', 255);
|
||||
$table->text('community_status')->nullable(true);
|
||||
$table->text('specialization')->nullable(true);
|
||||
$table->text('description_of_professional_activity')->nullable(true);
|
||||
$table->text('past_events')->nullable(true);
|
||||
$table->text('upcoming_events')->nullable(true);
|
||||
$table->text('under_curation_events')->nullable(true);
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('show_on_main')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
\kernel\App::$db->schema->dropIfExists('gestalt_profile');
|
||||
}
|
||||
};
|
118
kernel/app_modules/gestalt_profile/models/Gestalt_profile.php
Normal file
118
kernel/app_modules/gestalt_profile/models/Gestalt_profile.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||||
|
||||
// Добавить @property
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $status
|
||||
* @property int $show_on_main
|
||||
* @property int $user_id
|
||||
* @property string $fio
|
||||
* @property string $phone
|
||||
* @property string $email
|
||||
* @property string $city
|
||||
* @property string $photo
|
||||
* @property string $community_status
|
||||
* @property string $specialization
|
||||
* @property string $description_of_professional_activity
|
||||
* @property string $past_events
|
||||
* @property string $upcoming_events
|
||||
* @property string $under_curation_events
|
||||
* @property array $communityStatusArr
|
||||
* @property array $specializationArr
|
||||
*/
|
||||
class Gestalt_profile extends Model
|
||||
{
|
||||
const DISABLE_STATUS = 0;
|
||||
const ACTIVE_STATUS = 1;
|
||||
|
||||
const DONT_SHOW_ON_MAIN = 0;
|
||||
|
||||
const SHOW_ON_MAIN = 1;
|
||||
|
||||
protected $table = 'gestalt_profile';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'fio',
|
||||
'phone',
|
||||
'email',
|
||||
'city',
|
||||
'photo',
|
||||
'community_status',
|
||||
'specialization',
|
||||
'description_of_professional_activity',
|
||||
'past_events',
|
||||
'upcoming_events',
|
||||
'under_curation_events',
|
||||
'status',
|
||||
'show_on_main',
|
||||
];
|
||||
|
||||
public static function labels(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'Пользователь',
|
||||
'fio' => 'ФИО',
|
||||
'phone' => 'Телефон',
|
||||
'email' => 'Почта',
|
||||
'city' => 'Город',
|
||||
'photo' => 'Фото',
|
||||
'community_status' => 'Статус в сообществе',
|
||||
'specialization' => 'Специализация',
|
||||
'description_of_professional_activity' => 'Описание профессиональной деятельности',
|
||||
'past_events' => 'Прошедшие мероприятия',
|
||||
'upcoming_events' => 'Будущие мероприятия',
|
||||
'under_curation_events' => 'Под руководством специалиста',
|
||||
'status' => 'Статус',
|
||||
'show_on_main' => 'Показать на главной',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getStatus(): array
|
||||
{
|
||||
return [
|
||||
self::DISABLE_STATUS => "Не активный",
|
||||
self::ACTIVE_STATUS => "Активный",
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getShowOnMain(): array
|
||||
{
|
||||
return [
|
||||
self::DONT_SHOW_ON_MAIN => "Не показывать",
|
||||
self::SHOW_ON_MAIN => "Показывать",
|
||||
];
|
||||
}
|
||||
|
||||
public function relationships(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(GestaltProfileRelationship::class, 'gestalt_profile_id');
|
||||
}
|
||||
|
||||
public function getCommunityStatusArrAttribute(): array
|
||||
{
|
||||
return array_filter(explode(", ", $this->community_status));
|
||||
}
|
||||
|
||||
public function getSpecializationArrAttribute(): array
|
||||
{
|
||||
return array_filter(explode(", ", $this->specialization));
|
||||
}
|
||||
|
||||
public static function getCountProfiles()
|
||||
{
|
||||
return self::count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile\models\forms;
|
||||
|
||||
use kernel\FormModel;
|
||||
|
||||
class CreateGestalt_profileForm extends FormModel
|
||||
{
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
// Заполнить массив правил
|
||||
// Пример:
|
||||
// return [
|
||||
// 'label' => 'required|min-str-len:5|max-str-len:30',
|
||||
// 'entity' => 'required',
|
||||
// 'slug' => '',
|
||||
// 'status' => ''
|
||||
// ];
|
||||
return [
|
||||
'user_id' => 'integer',
|
||||
'fio' => 'required|min-str-len:5|max-str-len:80',
|
||||
'phone' => 'required|min-str-len:5|max-str-len:30',
|
||||
'email' => 'required|min-str-len:5|max-str-len:30',
|
||||
'city' => 'required|min-str-len:3|max-str-len:30',
|
||||
'photo' => '',
|
||||
'community_status' => '',
|
||||
'specialization' => '',
|
||||
'description_of_professional_activity' => '',
|
||||
'past_events' => '',
|
||||
'upcoming_events' => '',
|
||||
'under_curation_events' => '',
|
||||
'status' => 'integer',
|
||||
'show_on_main' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
25
kernel/app_modules/gestalt_profile/routs/gestalt_profile.php
Normal file
25
kernel/app_modules/gestalt_profile/routs/gestalt_profile.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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"], function (CGRouteCollector $router) {
|
||||
App::$collector->get('/', [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionIndex']);
|
||||
App::$collector->get('/create', [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionCreate']);
|
||||
App::$collector->post("/", [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionAdd']);
|
||||
App::$collector->get('/view/{id}', [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionView']);
|
||||
App::$collector->any('/update/{id}', [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionUpdate']);
|
||||
App::$collector->any("/edit/{id}", [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\app\modules\gestalt_profile\controllers\Gestalt_profileController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
});
|
||||
App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){
|
||||
App::$collector->group(['before' => 'bearer'], function (CgRouteCollector $router){
|
||||
$router->rest("gestalt_profile", [\kernel\app_modules\gestalt_profile\controllers\GestaltProfileRestController::class]);
|
||||
});
|
||||
});
|
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\gestalt_profile\services;
|
||||
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
use kernel\FormModel;
|
||||
|
||||
class Gestalt_profileService
|
||||
{
|
||||
protected Gestalt_profile $model;
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new Gestalt_profile();
|
||||
}
|
||||
|
||||
public function create(FormModel $form_model): false|Gestalt_profile
|
||||
{
|
||||
$model = new Gestalt_profile();
|
||||
// Пример заполнения:
|
||||
$model->user_id = $form_model->getItem('user_id');
|
||||
$model->fio = $form_model->getItem('fio');
|
||||
$model->phone = $form_model->getItem('phone');
|
||||
$model->email = $form_model->getItem('email');
|
||||
$model->city = $form_model->getItem('city');
|
||||
$model->photo = $form_model->getItem('photo');
|
||||
$model->community_status = $form_model->getItem('community_status');
|
||||
$model->specialization = $form_model->getItem('specialization');
|
||||
$model->description_of_professional_activity = $form_model->getItem('description_of_professional_activity');
|
||||
$model->past_events = $form_model->getItem('past_events');
|
||||
$model->upcoming_events = $form_model->getItem('upcoming_events');
|
||||
$model->under_curation_events = $form_model->getItem('under_curation_events');
|
||||
$model->status = $form_model->getItem('status');
|
||||
$model->show_on_main = $form_model->getItem('show_on_main');
|
||||
|
||||
if ($model->save()){
|
||||
return $model;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update(FormModel $form_model, Gestalt_profile $gestalt_profile): false|Gestalt_profile
|
||||
{
|
||||
// Пример обновления:
|
||||
$gestalt_profile->user_id = $form_model->getItem('user_id');
|
||||
$gestalt_profile->fio = $form_model->getItem('fio');
|
||||
$gestalt_profile->phone = $form_model->getItem('phone');
|
||||
$gestalt_profile->email = $form_model->getItem('email');
|
||||
$gestalt_profile->city = $form_model->getItem('city');
|
||||
$gestalt_profile->photo = $form_model->getItem('photo');
|
||||
$gestalt_profile->community_status = $form_model->getItem('community_status');
|
||||
$gestalt_profile->specialization = $form_model->getItem('specialization');
|
||||
$gestalt_profile->description_of_professional_activity = $form_model->getItem('description_of_professional_activity');
|
||||
$gestalt_profile->past_events = $form_model->getItem('past_events');
|
||||
$gestalt_profile->upcoming_events = $form_model->getItem('upcoming_events');
|
||||
$gestalt_profile->under_curation_events = $form_model->getItem('under_curation_events');
|
||||
$gestalt_profile->status = $form_model->getItem('status');
|
||||
$gestalt_profile->show_on_main = $form_model->getItem('show_on_main');
|
||||
|
||||
if ($gestalt_profile->save()){
|
||||
return $gestalt_profile;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getCount()
|
||||
{
|
||||
return Gestalt_profile::count();
|
||||
}
|
||||
|
||||
public static function getLast4(): array
|
||||
{
|
||||
return Gestalt_profile::query()->limit(4)->orderBy('id', 'desc')->get()->toArray();
|
||||
}
|
||||
}
|
55
kernel/app_modules/gestalt_profile/views/form.php
Normal file
55
kernel/app_modules/gestalt_profile/views/form.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @var Gestalt_profile $model
|
||||
*/
|
||||
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/gestalt_profile/edit/" . $model->id : "/admin/gestalt_profile", '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: "show_on_main", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->show_on_main ?? ''
|
||||
])
|
||||
->setLabel("Показать на главной")
|
||||
->setOptions(Gestalt_profile::getShowOnMain())
|
||||
->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();
|
90
kernel/app_modules/gestalt_profile/views/index.php
Normal file
90
kernel/app_modules/gestalt_profile/views/index.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $gestalt_profile
|
||||
* @var int $page_number
|
||||
* @var \kernel\CgView $view
|
||||
*/
|
||||
|
||||
use kernel\app_modules\gestalt_profile\models\Gestalt_profile;
|
||||
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;
|
||||
|
||||
$get = (new \kernel\Request())->get();
|
||||
|
||||
$view->setTitle("Список gestalt_profile");
|
||||
$view->setMeta([
|
||||
'description' => 'Список gestalt_profile системы'
|
||||
]);
|
||||
|
||||
//Для использования таблицы с моделью, необходимо создать таблицу в базе данных
|
||||
$table = new ListEloquentTable(new EloquentDataProvider(Gestalt_profile::class, [
|
||||
'currentPage' => $page_number,
|
||||
'perPage' => 8,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/gestalt_profile",
|
||||
'searchPrefix' => "",
|
||||
'searchParams' => $get,
|
||||
'fillable' => ['fio', 'photo', 'phone', 'email', 'city']
|
||||
]));
|
||||
|
||||
|
||||
//$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([
|
||||
// 'title' => [
|
||||
// 'filter' => [
|
||||
// 'class' => \Itguild\Tables\Filter\InputTextFilter::class,
|
||||
// 'value' => $get['title'] ?? ''
|
||||
// ]
|
||||
// ],
|
||||
//]);
|
||||
|
||||
$table->columns([
|
||||
"photo" => [
|
||||
"value" => function ($cell) {
|
||||
return \kernel\helpers\Html::img($cell, ['width' => '200px']);
|
||||
}]
|
||||
]);
|
||||
|
||||
$table->beforePrint(function () {
|
||||
return IconBtnCreateWidget::create(['url' => '/admin/gestalt_profile/create'])->run();
|
||||
});
|
||||
|
||||
$table->addAction(function ($row) {
|
||||
return IconBtnViewWidget::create(['url' => '/admin/gestalt_profile/view/' . $row['id']])->run();
|
||||
});
|
||||
$table->addAction(function ($row) {
|
||||
return IconBtnEditWidget::create(['url' => '/admin/gestalt_profile/update/' . $row['id']])->run();
|
||||
});
|
||||
$table->addAction(function ($row) {
|
||||
return IconBtnDeleteWidget::create(['url' => '/admin/gestalt_profile/delete/' . $row['id']])->run();
|
||||
});
|
||||
$table->create();
|
||||
$table->render();
|
32
kernel/app_modules/gestalt_profile/views/view.php
Normal file
32
kernel/app_modules/gestalt_profile/views/view.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $gestalt_profile
|
||||
*/
|
||||
|
||||
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, [
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/gestalt_profile",
|
||||
]));
|
||||
$table->beforePrint(function () use ($gestalt_profile) {
|
||||
$btn = IconBtnListWidget::create(['url' => '/admin/gestalt_profile'])->run();
|
||||
$btn .= IconBtnEditWidget::create(['url' => '/admin/gestalt_profile/update/' . $gestalt_profile->id])->run();
|
||||
$btn .= IconBtnDeleteWidget::create(['url' => '/admin/gestalt_profile/delete/' . $gestalt_profile->id])->run();
|
||||
return $btn;
|
||||
});
|
||||
|
||||
$table->rows([
|
||||
'photo' => function ($data) {
|
||||
return \kernel\helpers\Html::img($data, ['width' => '200px']);
|
||||
|
||||
},
|
||||
]);
|
||||
|
||||
$table->create();
|
||||
$table->render();
|
Reference in New Issue
Block a user