ADD: Se crearon las migraciones y los modelos
This commit is contained in:
parent
92bf244fe6
commit
4e1c5855af
26
app/Models/Device.php
Normal file
26
app/Models/Device.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Device extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'type_id',
|
||||
'brand',
|
||||
'serie',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
26
app/Models/DeviceModule.php
Normal file
26
app/Models/DeviceModule.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeviceModule extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'device_module';
|
||||
|
||||
protected $fillable = [
|
||||
'device_id',
|
||||
'module_id',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
17
app/Models/Error.php
Normal file
17
app/Models/Error.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Error extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'description',
|
||||
];
|
||||
|
||||
}
|
||||
25
app/Models/File.php
Normal file
25
app/Models/File.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'path',
|
||||
'md5',
|
||||
'record_id',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'url',
|
||||
];
|
||||
|
||||
}
|
||||
31
app/Models/Module.php
Normal file
31
app/Models/Module.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Module extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'municipality',
|
||||
'address',
|
||||
'colony',
|
||||
'longitude',
|
||||
'latitude',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'longitude' => 'decimal:8',
|
||||
'latitude' => 'decimal:8',
|
||||
'status' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
25
app/Models/Owner.php
Normal file
25
app/Models/Owner.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Owner extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'paternal',
|
||||
'maternal',
|
||||
'rfc',
|
||||
'curp',
|
||||
'address',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'full_name',
|
||||
];
|
||||
}
|
||||
28
app/Models/Package.php
Normal file
28
app/Models/Package.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Package extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'lot',
|
||||
'box_number',
|
||||
'starting_page',
|
||||
'ending_page',
|
||||
'module_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'starting_page' => 'integer',
|
||||
'ending_page' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
18
app/Models/Record.php
Normal file
18
app/Models/Record.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Record extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'vehicle_id',
|
||||
'user_id',
|
||||
'error_id',
|
||||
];
|
||||
|
||||
}
|
||||
18
app/Models/ScanHistory.php
Normal file
18
app/Models/ScanHistory.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ScanHistory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'scan_history';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'tag_id',
|
||||
];
|
||||
}
|
||||
18
app/Models/Tag.php
Normal file
18
app/Models/Tag.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'folio',
|
||||
'vehicle_id',
|
||||
'package_id',
|
||||
'status',
|
||||
];
|
||||
}
|
||||
22
app/Models/Vehicle.php
Normal file
22
app/Models/Vehicle.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Vehicle extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'vehicle';
|
||||
|
||||
protected $fillable = [
|
||||
'placa',
|
||||
'modelo',
|
||||
'marca',
|
||||
'nrpv',
|
||||
'owner_id',
|
||||
];
|
||||
|
||||
}
|
||||
27
app/Models/VehicleTagLog.php
Normal file
27
app/Models/VehicleTagLog.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VehicleTagLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'vehicle_tags_logs';
|
||||
|
||||
protected $fillable = [
|
||||
'vehicle_id',
|
||||
'tag_id',
|
||||
'cancellation_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'cancellation_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,9 +13,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('vehicle_id')->constrained('vehicles')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
|
||||
$table->foreignId('error_id')->constrained('errors')->onDelete('cascade');
|
||||
$table->foreignId('vehicle_id')->constrained('vehicle')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignId('error_id')->nullable()->constrained('errors')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,10 @@ public function up(): void
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('path');
|
||||
$table->string('md5')->nullable();
|
||||
$table->foreignId('record_id')->constrained('records')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,11 @@ public function up(): void
|
||||
{
|
||||
Schema::create('vehicle', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('placa')->unique();
|
||||
$table->string('modelo');
|
||||
$table->string('marca');
|
||||
$table->string('nrpv')->unique()->nullable(); // Número REPUVE
|
||||
$table->foreignId('owner_id')->nullable()->constrained('owners')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ public function up(): void
|
||||
{
|
||||
Schema::create('errors', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,12 @@ public function up(): void
|
||||
{
|
||||
Schema::create('owners', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('paternal');
|
||||
$table->string('maternal')->nullable();
|
||||
$table->string('rfc')->unique()->nullable();
|
||||
$table->string('curp')->unique()->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,13 @@ public function up(): void
|
||||
{
|
||||
Schema::create('modules', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('municipality');
|
||||
$table->string('address');
|
||||
$table->string('colony');
|
||||
$table->decimal('longitude', 10, 8)->nullable();
|
||||
$table->decimal('latitude', 10, 8)->nullable();
|
||||
$table->boolean('status')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,7 +13,12 @@ public function up(): void
|
||||
{
|
||||
Schema::create('device_module', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->constrained('devices')->cascadeOnDelete();
|
||||
$table->foreignId('module_id')->constrained('modules')->cascadeOnDelete();
|
||||
$table->boolean('status')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['device_id', 'module_id']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,10 @@ public function up(): void
|
||||
{
|
||||
Schema::create('devices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('type_id')->nullable()->constrained('device_types')->nullOnDelete();
|
||||
$table->string('brand');
|
||||
$table->string('serie')->unique();
|
||||
$table->boolean('status')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,11 @@ public function up(): void
|
||||
{
|
||||
Schema::create('packages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('lot');
|
||||
$table->string('box_number');
|
||||
$table->integer('starting_page');
|
||||
$table->integer('ending_page');
|
||||
$table->foreignId('module_id')->constrained('modules')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,10 @@ public function up(): void
|
||||
{
|
||||
Schema::create('tags', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('folio')->unique();
|
||||
$table->foreignId('vehicle_id')->nullable()->constrained('vehicle')->nullOnDelete();
|
||||
$table->foreignId('package_id')->nullable()->constrained('packages')->nullOnDelete();
|
||||
$table->enum('status', ['available', 'assigned', 'cancelled', 'lost'])->default('available');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ public function up(): void
|
||||
{
|
||||
Schema::create('vehicle_tags_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('vehicle_id')->constrained('vehicle')->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained('tags')->cascadeOnDelete();
|
||||
$table->timestamp('cancellation_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ public function up(): void
|
||||
{
|
||||
Schema::create('scan_history', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained('tags')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user