diff --git a/app/Models/Fault.php b/app/Models/Fault.php new file mode 100644 index 0000000..be57c6e --- /dev/null +++ b/app/Models/Fault.php @@ -0,0 +1,30 @@ + + */ + protected $fillable = [ + 'contact_name', + 'contact_phone', + 'description', + 'address', + 'status', + 'google_maps_link', + 'city', + ]; +} diff --git a/app/Models/User.php b/app/Models/User.php index 688eac1..6a6153a 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; - use Spatie\Permission\Traits\HasRoles; class User extends Authenticatable diff --git a/database/migrations/2024_11_08_020811_create_faults_table.php b/database/migrations/2024_11_08_020811_create_faults_table.php new file mode 100644 index 0000000..210e4c4 --- /dev/null +++ b/database/migrations/2024_11_08_020811_create_faults_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('contact_name'); // This column must exist + $table->string('contact_phone'); + $table->text('description'); + $table->string('address'); + $table->string('status'); + $table->string('google_maps_link'); + $table->string('city'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('faults'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 278d49d..47c7f64 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -3,6 +3,8 @@ namespace Database\Seeders; use App\Models\User; +use App\Models\Fault; + use Illuminate\Database\Seeder; use Spatie\Permission\Models\Role; @@ -53,6 +55,31 @@ public function run(): void $user->assignRole($userData['role']); } } + + Fault::firstOrCreate([ + 'contact_name' => 'Anthony', + 'contact_phone' => '666767222', + 'description' => 'No tenemos luz en el garaje', + 'address' => 'Carrer del mig, 4', + 'status' => 'En espera', + 'google_maps_link' => 'https://maps.google.com/long/url/link', + 'city' => 'Algemesi', + 'created_at' => now(), + 'updated_at' => now(), + ]); + + Fault::firstOrCreate([ + 'contact_name' => 'Amparo', + 'contact_phone' => '74645657', + 'description' => 'Se ha roto el reloj', + 'address' => 'Plaza Mayor 1', + 'status' => 'Realizado', + 'google_maps_link' => 'https://maps.google.com/long/url/link', + 'city' => 'Cataroja', + 'created_at' => now(), + 'updated_at' => now(), + ]); + } } diff --git a/resources/views/dashboard/faults.blade.php b/resources/views/dashboard/faults.blade.php new file mode 100644 index 0000000..4c1e8fe --- /dev/null +++ b/resources/views/dashboard/faults.blade.php @@ -0,0 +1,46 @@ + + +

+ {{ __('Averías') }} +

+
+ +
+
+
+ + + + + + + + + + + + + + @foreach ($faults as $fault) + + + + + + + + + + + + @endforeach + +
StatusCiutatTelefon
{{ $fault->status }}{{ $fault->city }}{{ $fault->contact_phone }} + + +
+
+
+
+ +
diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php index 47eda72..c0ae032 100644 --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -23,6 +23,11 @@ + diff --git a/routes/web.php b/routes/web.php index 534fe7c..f43fffe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route; use App\Models\User; +use App\Models\Fault; Route::get('/', function () { @@ -21,6 +22,10 @@ return view('dashboard.users', compact('users')); })->name('dashboard.users'); +Route::get('/dashboard/faults', function () { + $faults = \App\Models\Fault::all(); + return view('dashboard.faults', compact('faults')); +})->name('dashboard.faults'); Route::middleware('auth')->group(function () { Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');