add faults (routes, model, navigation, seeder and migration)
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build, push and deploy / builds (push) Successful in 5s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build, push and deploy / builds (push) Successful in 5s
				
			This commit is contained in:
		
							
								
								
									
										30
									
								
								app/Models/Fault.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/Models/Fault.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace App\Models; | ||||||
|  | 
 | ||||||
|  | use Illuminate\Database\Eloquent\Model; | ||||||
|  | 
 | ||||||
|  | use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||||
|  | use Illuminate\Notifications\Notifiable; | ||||||
|  | use Spatie\Permission\Traits\HasRoles; | ||||||
|  | 
 | ||||||
|  | class Fault extends Model | ||||||
|  | { | ||||||
|  |         use HasFactory, Notifiable; | ||||||
|  |         use HasRoles; | ||||||
|  |      | ||||||
|  |         /** | ||||||
|  |          * The attributes that are mass assignable. | ||||||
|  |          * | ||||||
|  |          * @var array<int, string> | ||||||
|  |          */ | ||||||
|  |         protected $fillable = [ | ||||||
|  |             'contact_name', | ||||||
|  |             'contact_phone', | ||||||
|  |             'description', | ||||||
|  |             'address', | ||||||
|  |             'status', | ||||||
|  |             'google_maps_link', | ||||||
|  |             'city', | ||||||
|  |         ]; | ||||||
|  | } | ||||||
| @@ -6,7 +6,6 @@ namespace App\Models; | |||||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||||
| use Illuminate\Foundation\Auth\User as Authenticatable; | use Illuminate\Foundation\Auth\User as Authenticatable; | ||||||
| use Illuminate\Notifications\Notifiable; | use Illuminate\Notifications\Notifiable; | ||||||
| 
 |  | ||||||
| use Spatie\Permission\Traits\HasRoles; | use Spatie\Permission\Traits\HasRoles; | ||||||
| 
 | 
 | ||||||
| class User extends Authenticatable | class User extends Authenticatable | ||||||
|   | |||||||
| @@ -0,0 +1,34 @@ | |||||||
|  | <?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('faults', function (Blueprint $table) { | ||||||
|  |             $table->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'); | ||||||
|  |     } | ||||||
|  | }; | ||||||
| @@ -3,6 +3,8 @@ | |||||||
| namespace Database\Seeders; | namespace Database\Seeders; | ||||||
| 
 | 
 | ||||||
| use App\Models\User; | use App\Models\User; | ||||||
|  | use App\Models\Fault; | ||||||
|  | 
 | ||||||
| use Illuminate\Database\Seeder; | use Illuminate\Database\Seeder; | ||||||
| use Spatie\Permission\Models\Role; | use Spatie\Permission\Models\Role; | ||||||
| 
 | 
 | ||||||
| @@ -53,6 +55,31 @@ class DatabaseSeeder extends Seeder | |||||||
|                 $user->assignRole($userData['role']); |                 $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(), | ||||||
|  |         ]); | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|   | |||||||
							
								
								
									
										46
									
								
								resources/views/dashboard/faults.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								resources/views/dashboard/faults.blade.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | |||||||
|  | <x-app-layout> | ||||||
|  |     <x-slot name="header"> | ||||||
|  |         <h2 class="font-semibold text-xl text-gray-800 leading-tight"> | ||||||
|  |             {{ __('Averías') }} | ||||||
|  |         </h2> | ||||||
|  |     </x-slot> | ||||||
|  | 
 | ||||||
|  |     <div class="py-12"> | ||||||
|  |         <div class="max-w-7xl mx-auto sm:px-6 lg:px-8"> | ||||||
|  |             <div class="overflow-x-auto py-4"> | ||||||
|  |                 <table class="min-w-full table-auto border-collapse"> | ||||||
|  |                     <thead> | ||||||
|  |                         <tr> | ||||||
|  |                             <!-- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th> --> | ||||||
|  |                             <!-- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th> --> | ||||||
|  |                             <!-- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Direcció</th> --> | ||||||
|  |                             <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th> | ||||||
|  |                             <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Ciutat</th> | ||||||
|  |                             <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Telefon</th> | ||||||
|  |                             <!-- <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Google Maps</th> --> | ||||||
|  |                         </tr> | ||||||
|  |                     </thead> | ||||||
|  |                     <tbody class="bg-white divide-y divide-gray-200"> | ||||||
|  |                         @foreach ($faults as $fault) | ||||||
|  |                             <tr> | ||||||
|  |                                 <!-- <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{{ $fault->id }}</td> --> | ||||||
|  |                                 <!-- <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $fault->contact_name }}</td> --> | ||||||
|  |                                 <!-- <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $fault->address }}</td> --> | ||||||
|  |                                 <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $fault->status }}</td> | ||||||
|  |                                 <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $fault->city }}</td> | ||||||
|  |                                 <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $fault->contact_phone }}</td> | ||||||
|  |                                 <!-- <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $fault->google_maps_link }}</td> --> | ||||||
|  | 
 | ||||||
|  |                                 <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> | ||||||
|  |                                     <button class="text-indigo-600 hover:text-indigo-900">Edit</button> | ||||||
|  |                                     <button class="text-red-600 hover:text-red-900 ml-4">Delete</button> | ||||||
|  |                                 </td> | ||||||
|  |                             </tr> | ||||||
|  |                         @endforeach | ||||||
|  |                     </tbody> | ||||||
|  |                 </table> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |     </div> | ||||||
|  | 
 | ||||||
|  | </x-app-layout> | ||||||
| @@ -23,6 +23,11 @@ | |||||||
|                     </x-nav-link> |                     </x-nav-link> | ||||||
|                 </div> |                 </div> | ||||||
| 
 | 
 | ||||||
|  |                 <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"> | ||||||
|  |                     <x-nav-link :href="route('dashboard.faults')" :active="request()->routeIs('dashboard.faults')"> | ||||||
|  |                         {{ __('Averías') }} | ||||||
|  |                     </x-nav-link> | ||||||
|  |                 </div> | ||||||
| 
 | 
 | ||||||
|             </div> |             </div> | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ use App\Http\Controllers\ProfileController; | |||||||
| use Illuminate\Support\Facades\Route; | use Illuminate\Support\Facades\Route; | ||||||
| 
 | 
 | ||||||
| use App\Models\User; | use App\Models\User; | ||||||
|  | use App\Models\Fault; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Route::get('/', function () { | Route::get('/', function () { | ||||||
| @@ -21,6 +22,10 @@ Route::get('/dashboard/users', function () { | |||||||
|     return view('dashboard.users', compact('users')); |     return view('dashboard.users', compact('users')); | ||||||
| })->name('dashboard.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::middleware('auth')->group(function () { | ||||||
|     Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); |     Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 albert
					albert