feat: implement module generator with automated migration, model, and view creation
This commit is contained in:
@@ -54,6 +54,7 @@ class ModuleGeneratorController extends Controller
|
||||
case 'decimal': $dbType = 'decimal'; break;
|
||||
case 'date': $dbType = 'date'; break;
|
||||
case 'datetime': $dbType = 'dateTime'; break;
|
||||
case 'time': $dbType = 'time'; break;
|
||||
case 'long-text': $dbType = 'longText'; break;
|
||||
case 'boolean': $dbType = 'boolean'; break;
|
||||
default: $dbType = 'string'; break;
|
||||
@@ -90,23 +91,21 @@ class ModuleGeneratorController extends Controller
|
||||
if (File::exists($templatePath)) {
|
||||
$templateContent = File::get($templatePath);
|
||||
|
||||
// Simple replacements in template
|
||||
$templateContent = str_replace('use App\Models\RadiographicTest;', "use App\Models\\{$modelName};", $templateContent);
|
||||
$templateContent = str_replace('$title = "Radiographic Test";', "\$title = \"{$title}\";", $templateContent);
|
||||
$templateContent = str_replace('$tableName = "radiographic_tests";', "\$tableName = \"{$tableName}\";", $templateContent);
|
||||
// Placeholder replacements
|
||||
$templateContent = str_replace('[[MODEL_NAME]]', $modelName, $templateContent);
|
||||
$templateContent = str_replace('[[TITLE]]', $title, $templateContent);
|
||||
$templateContent = str_replace('[[TABLE_NAME]]', $tableName, $templateContent);
|
||||
|
||||
// Generate relationDatas
|
||||
$relationDatasCode = "\$relationDatas = [\n";
|
||||
$relationDatasCode = "[\n";
|
||||
foreach ($request->columns as $column) {
|
||||
$colName = Str::snake($column['name']);
|
||||
$colType = $column['type'];
|
||||
$relationDatasCode .= " '{$colName}' => [\n 'type' => '{$colType}',\n ],\n";
|
||||
}
|
||||
$relationDatasCode .= "];";
|
||||
$relationDatasCode .= "]";
|
||||
|
||||
// Replace the hardcoded relationDatas in template
|
||||
$pattern = '/\$relationDatas = \[.*?\];/s';
|
||||
$templateContent = preg_replace($pattern, $relationDatasCode, $templateContent);
|
||||
$templateContent = str_replace('[[RELATION_DATAS]]', $relationDatasCode, $templateContent);
|
||||
|
||||
File::put($viewPath, $templateContent);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Products extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'products';
|
||||
protected $guarded = [];
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 327 KiB |
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateProductsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->nullable();
|
||||
$table->decimal('price', 15, 2)->nullable();
|
||||
$table->string('category')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
}
|
||||
@@ -60,10 +60,13 @@
|
||||
<option value="decimal">Decimal (Price/Ratio)</option>
|
||||
<option value="date">Date</option>
|
||||
<option value="datetime">DateTime</option>
|
||||
<option value="time">Time</option>
|
||||
<option value="long-text">Long Text (Textarea)</option>
|
||||
<option value="boolean">Boolean (Yes/No)</option>
|
||||
<option value="select">Select (Dropdown)</option>
|
||||
<option value="select">Select (Static Dropdown)</option>
|
||||
<option value="select-dropdown">Select (API Dropdown)</option>
|
||||
<option value="link-search">Link Search (File/PDF)</option>
|
||||
<option value="auto-complete">Auto Complete</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@@ -85,7 +88,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section('script')
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(function() {
|
||||
let colIndex = 1;
|
||||
@@ -103,10 +106,13 @@
|
||||
<option value="decimal">Decimal (Price/Ratio)</option>
|
||||
<option value="date">Date</option>
|
||||
<option value="datetime">DateTime</option>
|
||||
<option value="time">Time</option>
|
||||
<option value="long-text">Long Text (Textarea)</option>
|
||||
<option value="boolean">Boolean (Yes/No)</option>
|
||||
<option value="select">Select (Dropdown)</option>
|
||||
<option value="select">Select (Static Dropdown)</option>
|
||||
<option value="select-dropdown">Select (API Dropdown)</option>
|
||||
<option value="link-search">Link Search (File/PDF)</option>
|
||||
<option value="auto-complete">Auto Complete</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
|
||||
@@ -2,177 +2,46 @@
|
||||
/**
|
||||
* CITRUS CMS - Datagrid Module Template
|
||||
*
|
||||
* Bu şablon, DevExtreme (dxDataGrid) kullanarak hızlıca CRUD modülleri oluşturmak için tasarlanmıştır.
|
||||
* Aşağıdaki değişkenler ve yapılar, modülün hem listeleme hem de düzenleme davranışını belirler.
|
||||
*
|
||||
* --- TEMEL DEĞİŞKENLER ---
|
||||
* Bu şablon, Module Generator tarafından otomatik olarak doldurulur.
|
||||
*/
|
||||
|
||||
use App\Models\RadiographicTest; // Modülün bağlı olduğu Eloquent Model
|
||||
use App\Models\[[MODEL_NAME]];
|
||||
|
||||
// Modülün sayfa başlığı
|
||||
$title = "Radiographic Test";
|
||||
|
||||
// Veritabanındaki tablo adı (CRUD işlemleri için kritik)
|
||||
$tableName = "radiographic_tests";
|
||||
|
||||
// Genişlik ayarı
|
||||
// Modül Ayarları
|
||||
$title = "[[TITLE]]";
|
||||
$tableName = "[[TABLE_NAME]]";
|
||||
$tableWidth = "100%";
|
||||
|
||||
|
||||
/**
|
||||
* --- RELATION DATAS (Sütun Özelleştirmeleri) ---
|
||||
*
|
||||
* Her bir sütunun veri tipini ve davranışını burada tanımlayabilirsiniz.
|
||||
* Mevcut Tipler: string, integer, decimal, float, date, datetime, time,
|
||||
* select, select-dropdown, link-search, long-text, multiple-choice, auto-complete
|
||||
* --- Sütun Özelleştirmeleri ---
|
||||
*/
|
||||
$relationDatas = [
|
||||
'report_file' => [
|
||||
'type' => 'link-search', // PDF/Dosya önizleme ve linki
|
||||
'html' => '<i class="fa fa-pdf"></i>',
|
||||
'caption' => 'PDF Report', // Sütun başlığını ezmek için
|
||||
'allowEditing' => true, // Hücre içinde manuel path düzenleme
|
||||
],
|
||||
'rt_result' => [
|
||||
'type' => 'select', // Sabit seçenekli açılır menü
|
||||
'dataSource' => [
|
||||
['id' => 'ACCEPTED', 'name' => 'ACCEPTED'],
|
||||
['id' => 'REJECTED', 'name' => 'REJECTED'],
|
||||
['id' => 'REPAIR', 'name' => 'REPAIR'],
|
||||
],
|
||||
],
|
||||
'welding_date' => [
|
||||
'type' => 'date', // Tarih seçici (YYYY-MM-DD)
|
||||
],
|
||||
'created_at' => [
|
||||
'type' => 'datetime', // Tarih ve Saat seçici
|
||||
],
|
||||
'shift_time' => [
|
||||
'type' => 'time', // Saat seçici
|
||||
],
|
||||
'rt_scope' => [
|
||||
'type' => 'integer', // Tam sayı girişi
|
||||
],
|
||||
'large_val' => [
|
||||
'type' => 'bigint', // Büyük tam sayı girişi
|
||||
],
|
||||
'price' => [
|
||||
'type' => 'decimal', // Ondalıklı sayı girişi (Hassas)
|
||||
],
|
||||
'ratio' => [
|
||||
'type' => 'float', // Ondalıklı sayı girişi
|
||||
],
|
||||
'description' => [
|
||||
'type' => 'long-text', // Çok satırlı metin (TextArea)
|
||||
],
|
||||
'tags' => [
|
||||
'type' => 'multiple-choice', // Çoklu seçim (Etiket mantığı)
|
||||
'dataSource' => [
|
||||
['id' => 'tag1', 'name' => 'Tag 1'],
|
||||
['id' => 'tag2', 'name' => 'Tag 2'],
|
||||
],
|
||||
],
|
||||
'category' => [
|
||||
'type' => 'select-dropdown', // Arama yapılabilir açılır menü
|
||||
'dataSource' => 'api/categories', // URL'den veri çekebilir
|
||||
],
|
||||
'username' => [
|
||||
'type' => 'auto-complete', // Otomatik tamamlama (Yazarken öneri)
|
||||
],
|
||||
'search_query' => [
|
||||
'type' => 'fuzzy-autocomplete', // Esnek aramalı otomatik tamamlama
|
||||
],
|
||||
'metadata' => [
|
||||
'type' => 'json', // JSON veri tipi (Görsel düzenleyici)
|
||||
],
|
||||
'raw_config' => [
|
||||
'type' => 'input-json', // Ham JSON girişi
|
||||
],
|
||||
'status_text' => [
|
||||
'type' => 'string', // Standart kısa metin girişi
|
||||
],
|
||||
'custom_field' => [
|
||||
'type' => 'text', // Standart metin girişi (string ile benzer)
|
||||
],
|
||||
];
|
||||
$relationDatas = [[RELATION_DATAS]];
|
||||
|
||||
/**
|
||||
* --- BLOCK GROUPS (Sütun Gruplandırma) ---
|
||||
*
|
||||
* Datagrid üzerinde sütunları "Banded Columns" (Gruplanmış Başlıklar) şeklinde gösterir.
|
||||
* Her key bir grup başlığıdır, value ise o gruba ait sütun isimleridir.
|
||||
* --- Sütun Gruplandırma ---
|
||||
*/
|
||||
$blockGroup = [
|
||||
'General Info' => [
|
||||
'report_file',
|
||||
'contractor',
|
||||
'project',
|
||||
],
|
||||
'Invoice Details' => [
|
||||
'invoice_number',
|
||||
'invoice_date',
|
||||
],
|
||||
'Technical Specs' => [
|
||||
'design_area',
|
||||
'line_specification',
|
||||
'line_number',
|
||||
'fluid_code',
|
||||
],
|
||||
'RT Test Data' => [
|
||||
'rt_scope',
|
||||
'rt_request_no',
|
||||
'rt_request_date',
|
||||
'rt_report',
|
||||
'rt_test_date',
|
||||
'rt_result',
|
||||
],
|
||||
'Other' => [
|
||||
'other',
|
||||
],
|
||||
'General' => array_keys($relationDatas),
|
||||
];
|
||||
|
||||
/**
|
||||
* --- UPLOAD CONFIGURATION ---
|
||||
*
|
||||
* Sayfanın üst kısmında bulunan toplu dosya yükleme mekanizması ayarları.
|
||||
*/
|
||||
$firstUploadFolder = '004_QA/0001_RT/'; // Dosyaların yükleneceği dizin (public/storage altı)
|
||||
$firstUploadTitle = 'Upload PDF Reports'; // Yükleme butonu metni
|
||||
|
||||
/**
|
||||
* --- EKSTRA AYARLAR (Opsiyonel) ---
|
||||
*/
|
||||
// $tableType = "datagrid"; // Varsayılan "datagrid". Farklı görünüm varsa değiştirilebilir.
|
||||
// $excepts = ['created_at', 'updated_at']; // Listelenmesini istemediğiniz sütunlar
|
||||
// $requiredFields = ['invoice_number', 'welding_date']; // Zorunlu alanlar
|
||||
// $noRemoteOperations = true; // Tüm işlemlerin client-side yapılmasını zorlamak için
|
||||
?>
|
||||
|
||||
<!-- Sayfa Özel Scriptleri -->
|
||||
<script>
|
||||
$(function () {
|
||||
// Sayfa yüklendiğinde çalışacak özel kodlar
|
||||
console.log("{{ $title }} module loaded.");
|
||||
});
|
||||
|
||||
// Custom DevExtreme Event Handlers buraya eklenebilir
|
||||
</script>
|
||||
|
||||
<!-- Sayfa Özel Stilleri -->
|
||||
<style>
|
||||
/* Tabloya özel CSS düzenlemeleri */
|
||||
.dx-datagrid-headers {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
/* Sayfaya özel CSS */
|
||||
</style>
|
||||
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<!-- Üst Kısım: Dosya Yükleme Paneli -->
|
||||
@include("admin.type.document.upload")
|
||||
<!-- Dosya Yükleme Paneli (Opsiyonel) -->
|
||||
{{-- @include("admin.type.document.upload") --}}
|
||||
|
||||
<!-- Alt Kısım: Ana Datagrid Bloğu -->
|
||||
<!-- Ana Datagrid Bloğu -->
|
||||
@include("components.blocks.module-block")
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* CITRUS CMS - Datagrid Module Template
|
||||
*
|
||||
* Bu şablon, Module Generator tarafından otomatik olarak doldurulur.
|
||||
*/
|
||||
|
||||
use App\Models\Products;
|
||||
|
||||
// Modül Ayarları
|
||||
$title = "Products";
|
||||
$tableName = "products";
|
||||
$tableWidth = "100%";
|
||||
|
||||
/**
|
||||
* --- Sütun Özelleştirmeleri ---
|
||||
*/
|
||||
$relationDatas = [
|
||||
'title' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
'price' => [
|
||||
'type' => 'decimal',
|
||||
],
|
||||
'category' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* --- Sütun Gruplandırma ---
|
||||
*/
|
||||
$blockGroup = [
|
||||
'General' => array_keys($relationDatas),
|
||||
];
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
console.log("{{ $title }} module loaded.");
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Sayfaya özel CSS */
|
||||
</style>
|
||||
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<!-- Dosya Yükleme Paneli (Opsiyonel) -->
|
||||
{{-- @include("admin.type.document.upload") --}}
|
||||
|
||||
<!-- Ana Datagrid Bloğu -->
|
||||
@include("components.blocks.module-block")
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user