فهرست منبع

Created order, order status, object type models, seeders, migrations

Alexander Musikhin 9 ماه پیش
والد
کامیت
a0b0fb1cdb

+ 93 - 0
app/Http/Controllers/OrderController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\Dictionary\Area;
+use App\Models\Dictionary\District;
+use Illuminate\Http\Request;
+
+class OrderController extends Controller
+{
+    protected array $data = [
+        'active'    => 'orders',
+        'title'     => 'Заказы',
+        'id'        => 'orders',
+//        'header'    => [
+//            'id'                        => 'ID',
+//            'year'                      => 'Год',
+//            'nomenclature_number'       => 'Номер номенклатуры',
+//            'article'                   => 'Артикул',
+//            'manufacturer'              => 'Производитель',
+//            'name_tz'                   => 'Наименование ТЗ',
+//            'type_tz'                   => 'Тип по ТЗ',
+//            'type'                      => 'Тип',
+//            'manufacturer_name'         => 'Наименование производителя',
+//            'sizes'                     => 'Размеры',
+//            'price_status'              => 'Статус цены',
+//            'product_price_txt'         => 'Цена товара',
+//            'installation_price_txt'    => 'Цена установки',
+//            'service_price_txt'         => 'Цена обслуживания',
+//            'total_price_txt'           => 'Итоговая цена',
+//            'note'                      => 'Примечания',
+//            'created_at'                => 'Дата создания',
+//        ]
+    ];
+
+    /**
+     * Display a listing of the resource.
+     */
+    public function index()
+    {
+        return view('orders.index', $this->data);
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     */
+    public function create()
+    {
+        $this->data['districts'] = District::get()->pluck('name', 'id');
+        $this->data['areas'] = Area::get()->pluck('name', 'id');
+        return view('orders.edit', $this->data);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     */
+    public function show(string $id)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     */
+    public function edit(string $id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     */
+    public function update(Request $request, string $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     */
+    public function destroy(string $id)
+    {
+        //
+    }
+}

+ 10 - 0
app/Models/Brigadier.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Brigadier extends Model
+{
+    protected $fillable = ['name'];
+}

+ 10 - 0
app/Models/ObjectType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ObjectType extends Model
+{
+    protected $fillable = ['name'];
+}

+ 1 - 1
app/Models/Order.php

@@ -19,6 +19,6 @@ class Order extends Model
         'installation_date',
         'brigadier',
         'tg_group_name',
-        'tg_group_id',
+        'tg_group_link',
     ];
 }

+ 10 - 0
app/Models/OrderStatus.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class OrderStatus extends Model
+{
+    protected $fillable = ['name'];
+}

+ 28 - 0
database/migrations/2025_03_04_153327_create_brigadiers_table.php

@@ -0,0 +1,28 @@
+<?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('brigadiers', function (Blueprint $table) {
+            $table->id();
+            $table->string('name')->unique();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('brigadiers');
+    }
+};

+ 28 - 0
database/migrations/2025_03_04_153350_create_object_types_table.php

@@ -0,0 +1,28 @@
+<?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('object_types', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('object_types');
+    }
+};

+ 28 - 0
database/migrations/2025_03_04_153402_create_order_statuses_table.php

@@ -0,0 +1,28 @@
+<?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('order_statuses', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('order_statuses');
+    }
+};

+ 3 - 2
database/migrations/2025_02_23_205828_create_orders_table.php → database/migrations/2025_03_24_153700_create_orders_table.php

@@ -18,12 +18,13 @@ return new class extends Migration
             $table->foreignId('district_id')->constrained('districts')->restrictOnDelete();// округ
             $table->foreignId('area_id')->constrained('areas')->restrictOnDelete();        // район
             $table->string('object_address');                                                   // адрес объекта
-            $table->string('object_type')->nullable();                                          // тип объекта
+            $table->foreignId('object_type_id')->constrained('object_types')->restrictOnDelete();// тип объекта
             $table->date('contract_date')->nullable();                                          // дата договора
             $table->string('contract_number')->nullable();                                      // номер дог-ра
             $table->text('comment')->nullable();                                                // комментарий
             $table->date('installation_date')->nullable();                                      // дата монтажа
-            $table->string('brigadier')->nullable();                                            // бригадир
+            $table->foreignId('brigadier_id')->constrained('brigadiers')->restrictOnDelete(); // бригадир
+            $table->foreignId('order_status_id')->constrained('order_statuses')->restrictOnDelete(); // статус объекта
             $table->string('tg_group_name')->nullable();
             $table->string('tg_group_id')->nullable();
             $table->timestamps();

+ 2 - 0
database/seeders/DatabaseSeeder.php

@@ -24,5 +24,7 @@ class DatabaseSeeder extends Seeder
 
         $this->call(DistrictSeeder::class);
         $this->call(AreaSeeder::class);
+        $this->call(ObjectTypeSeeder::class);
+        $this->call(OrderStatusSeeder::class);
     }
 }

+ 20 - 0
database/seeders/ObjectTypeSeeder.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\ObjectType;
+use Illuminate\Database\Seeder;
+
+class ObjectTypeSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        ObjectType::query()->updateOrCreate(['id' => 1], ['name' => 'Дворовые территории']);
+        ObjectType::query()->updateOrCreate(['id' => 2], ['name' => 'Дошкольное образование']);
+        ObjectType::query()->updateOrCreate(['id' => 3], ['name' => 'Знаковые объекты']);
+        ObjectType::query()->updateOrCreate(['id' => 4], ['name' => 'Образование']);
+    }
+}

+ 20 - 0
database/seeders/OrderStatusSeeder.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\OrderStatus;
+use Illuminate\Database\Seeder;
+
+class OrderStatusSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     */
+    public function run(): void
+    {
+        OrderStatus::query()->updateOrCreate(['id' => 1], ['name' => 'Новый']);
+        OrderStatus::query()->updateOrCreate(['id' => 2], ['name' => 'Готов к монтажу']);
+        OrderStatus::query()->updateOrCreate(['id' => 3], ['name' => 'Готов к сдаче']);
+        OrderStatus::query()->updateOrCreate(['id' => 4], ['name' => 'Сдан']);
+    }
+}