first commit

This commit is contained in:
brusnitsyn
2025-10-31 16:48:05 +09:00
commit 8b650558e2
143 changed files with 24664 additions and 0 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@@ -0,0 +1,49 @@
<?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
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -0,0 +1,35 @@
<?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
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -0,0 +1,57 @@
<?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
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,32 @@
<?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
{
Schema::create('document_templates', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description')->nullable();
$table->longText('content');
$table->json('variables');
$table->string('source_path')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('document_templates');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use App\Models\DocumentTemplate;
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
{
Schema::create('document_template_variables', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(DocumentTemplate::class, 'document_template_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('document_template_variables');
}
};

View File

@@ -0,0 +1,33 @@
<?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
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Seeders;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
}
}

View File

@@ -0,0 +1,208 @@
<?php
namespace Database\Seeders;
use App\Models\DocumentTemplate;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DocumentTemplateSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DocumentTemplate::create([
'name' => 'Договор подряда (упрощенный)',
'content' => [
'metadata' => [
'title' => 'Договор подряда',
'version' => '1.0'
],
'structure' => [
[
'id' => 'header',
'type' => 'section',
'enabled' => true,
'elements' => [
[
'id' => 'header_title',
'type' => 'heading',
'content' => 'ДОГОВОР ПОДРЯДА № <span class="placeholder" data-variable="contract_number">[номер]</span>'
],
[
'id' => 'header_date',
'type' => 'html',
'content' => '<table style="width: 100%; border: none; margin: 20px 0;">
<tr>
<td style="width: 50%; border: none;">г. <span class="placeholder" data-variable="city">[город]</span></td>
<td style="width: 50%; border: none; text-align: right;">«<span class="placeholder" data-variable="day">[день]</span>» <span class="placeholder" data-variable="month">[месяц]</span> <span class="placeholder" data-variable="year">[год]</span> г.</td>
</tr>
</table>',
'variables' => [
[
'name' => 'city',
'type' => 'select',
'label' => 'Город',
'options' => [
'Москва' => 'г. Москва',
'Санкт-Петербург' => 'г. Санкт-Петербург',
'Новосибирск' => 'г. Новосибирск',
'Екатеринбург' => 'г. Екатеринбург'
],
'default' => 'Москва'
],
'day', 'month', 'year' // простые текстовые поля
]
]
]
],
[
'id' => 'preamble',
'type' => 'section',
'enabled' => true,
'elements' => [
[
'id' => 'preamble_title',
'type' => 'heading',
'content' => '1. ПРЕАМБУЛА'
],
[
'id' => 'preamble_text',
'type' => 'html',
'content' => '<p><span class="placeholder" data-variable="client_type">[Тип заказчика]</span> <span class="placeholder" data-variable="client_name">[Ф.И.О. или наименование Заказчика]</span>, именуемый в дальнейшем «Заказчик», с одной стороны, и <span class="placeholder" data-variable="contractor_type">[Тип подрядчика]</span> <span class="placeholder" data-variable="contractor_name">[Ф.И.О. или наименование Подрядчика]</span>, именуемый в дальнейшем «Подрядчик», с другой стороны, заключили настоящий договор о нижеследующем:</p>',
'variables' => [
[
'name' => 'client_type',
'type' => 'select',
'label' => 'Тип заказчика',
'options' => [
'Индивидуальный предприниматель' => 'Индивидуальный предприниматель',
'Общество с ограниченной ответственностью' => 'Общество с ограниченной ответственностью',
'Физическое лицо' => 'Физическое лицо'
],
'default' => 'Индивидуальный предприниматель'
],
'client_name',
[
'name' => 'contractor_type',
'type' => 'select',
'label' => 'Тип подрядчика',
'options' => [
'Индивидуальный предприниматель' => 'Индивидуальный предприниматель',
'Общество с ограниченной ответственностью' => 'Общество с ограниченной ответственностью',
'Физическое лицо' => 'Физическое лицо'
],
'default' => 'Индивидуальный предприниматель'
],
'contractor_name'
]
]
]
],
[
'id' => 'subject',
'type' => 'section',
'enabled' => true,
'elements' => [
[
'id' => 'subject_title',
'type' => 'heading',
'content' => '2. ПРЕДМЕТ ДОГОВОРА'
],
[
'id' => 'subject_text',
'type' => 'html',
'content' => '<p>2.1. Подрядчик обязуется выполнить следующие работы: <span class="placeholder" data-variable="work_type">[вид работ]</span>, а Заказчик обязуется принять результат работ и оплатить его.</p>',
'variables' => [
[
'name' => 'work_type',
'type' => 'select',
'label' => 'Вид работ',
'options' => [
'ремонтные' => 'ремонтные работы',
'строительные' => 'строительные работы',
'отделочные' => 'отделочные работы',
'монтажные' => 'монтажные работы',
'проектные' => 'проектные работы'
],
'default' => 'ремонтные'
]
]
],
[
'id' => 'subject_details',
'type' => 'html',
'content' => '<p>2.2. Подробное описание работ: <span class="placeholder" data-variable="work_description">[описание работ]</span>.</p>',
'variables' => ['work_description']
]
]
],
[
'id' => 'payment',
'type' => 'section',
'enabled' => true,
'elements' => [
[
'id' => 'payment_title',
'type' => 'heading',
'content' => '3. СТОИМОСТЬ РАБОТ И ПОРЯДОК РАСЧЕТОВ'
],
[
'id' => 'payment_text',
'type' => 'html',
'content' => '<p>3.1. Стоимость работ составляет: <span class="placeholder" data-variable="work_price">[сумма]</span> рублей.</p>',
'variables' => ['work_price']
],
[
'id' => 'payment_method',
'type' => 'html',
'content' => '<p>3.2. Форма оплаты: <span class="placeholder" data-variable="payment_method">[форма оплаты]</span>.</p>',
'variables' => [
[
'name' => 'payment_method',
'type' => 'radio',
'label' => 'Форма оплаты',
'options' => [
'cash' => 'Наличный расчет',
'non-cash' => 'Безналичный расчет',
'advance' => 'Авансовый платеж'
],
'default' => 'non-cash'
]
]
]
]
],
[
'id' => 'signatures',
'type' => 'section',
'enabled' => true,
'elements' => [
[
'id' => 'signatures_table',
'type' => 'html',
'content' => '<table style="width: 100%; border-collapse: collapse; margin-top: 40px;">
<tr>
<td style="width: 50%; border: none; vertical-align: top;">
<strong>ЗАКАЗЧИК:</strong><br>
<span class="placeholder" data-variable="client_name">[Наименование/Ф.И.О.]</span><br>
Подпись: ________________ / <span class="placeholder" data-variable="client_signature">[Ф.И.О.]</span> /
</td>
<td style="width: 50%; border: none; vertical-align: top;">
<strong>ПОДРЯДЧИК:</strong><br>
<span class="placeholder" data-variable="contractor_name">[Наименование/Ф.И.О.]</span><br>
Подпись: ________________ / <span class="placeholder" data-variable="contractor_signature">[Ф.И.О.]</span> /
</td>
</tr>
</table>',
'variables' => ['client_name', 'client_signature', 'contractor_name', 'contractor_signature']
]
]
]
]
]
]);
}
}