Compare commits
No commits in common. "610eebf66ab7478908bdec22e0502c8d926c280c" and "c72ba4d7e3c47acf5bdad8a7212f824d3271b0f0" have entirely different histories.
610eebf66a
...
c72ba4d7e3
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Dashboard;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
|
|
||||||
class DashboardIndexController extends Controller
|
|
||||||
{
|
|
||||||
public function create(): View
|
|
||||||
{
|
|
||||||
return view('dashboard.index');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Dashboard;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
|
|
||||||
class DashboardIndexController extends Controller
|
|
||||||
{
|
|
||||||
public function create(): View
|
|
||||||
{
|
|
||||||
return view('dashboard.users');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
<?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,6 +6,7 @@
|
|||||||
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
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
<?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,10 +3,11 @@
|
|||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Fault;
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -15,75 +16,27 @@ class DatabaseSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// Create roles if they don't already exist
|
// User::factory(10)->create();
|
||||||
$roles = ['admin', 'privileged'];
|
|
||||||
|
|
||||||
foreach ($roles as $roleName) {
|
// Create roles
|
||||||
// Check if the role already exists
|
$adminRole = Role::create(['name' => 'admin']);
|
||||||
if (!Role::where('name', $roleName)->exists()) {
|
$privilegedRole = Role::create(['name' => 'privileged']);
|
||||||
Role::create(['name' => $roleName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the superuser already exists
|
// Create permissions
|
||||||
$user = User::firstOrCreate([
|
$editPermission = Permission::create(['name' => 'edit articles']);
|
||||||
'email' => 'superuser@admin.com',
|
$deletePermission = Permission::create(['name' => 'delete articles']);
|
||||||
'name' => 'superuser',
|
|
||||||
'password' => bcrypt('12341234'),
|
// Assign permissions to roles
|
||||||
|
$adminRole->givePermissionTo([$editPermission, $deletePermission]);
|
||||||
|
$privilegedRole->givePermissionTo($editPermission);
|
||||||
|
|
||||||
|
User::factory()->create([
|
||||||
|
'name' => 'Test User',
|
||||||
|
'email' => 'test@example.com',
|
||||||
|
'password' => '12341234'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Assign the role to the superuser
|
$user = User::find(1); // get a user
|
||||||
$user->assignRole('admin');
|
$user->assignRole('admin');
|
||||||
|
|
||||||
// Create other users as before
|
|
||||||
$users = [
|
|
||||||
['name' => 'John Doe', 'email' => 'john@doe.com', 'role' => 'privileged'],
|
|
||||||
['name' => 'Chuck Norris', 'email' => 'chuck@norris.com'],
|
|
||||||
['name' => 'Marios Bros', 'email' => 'mario@bros.com'],
|
|
||||||
['name' => 'Ada Lovelace', 'email' => 'ada@lovelace.com'],
|
|
||||||
['name' => 'Hulk Hogan', 'email' => 'hulk@hogart.com'],
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($users as $userData) {
|
|
||||||
$user = User::firstOrCreate([
|
|
||||||
'email' => $userData['email'],
|
|
||||||
'name' => $userData['name'],
|
|
||||||
'password' => bcrypt('12341234'),
|
|
||||||
]);
|
|
||||||
if (array_key_exists('role', $userData) && $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(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,5 +14,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</x-app-layout>
|
</x-app-layout>
|
@ -1,46 +0,0 @@
|
|||||||
<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>
|
|
@ -1,45 +0,0 @@
|
|||||||
<x-app-layout>
|
|
||||||
<x-slot name="header">
|
|
||||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
|
||||||
{{ __('Usuarios') }}
|
|
||||||
</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">Email</th>
|
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created At</th>
|
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Updated At</th>
|
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Roles</th>
|
|
||||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="bg-white divide-y divide-gray-200">
|
|
||||||
@foreach ($users as $user)
|
|
||||||
<tr>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">1</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $user->name }}</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $user->email }}</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $user->created_at }}</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $user->updated_at }}</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ implode(', ', $user->getRoleNames()->toArray()) }}</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>
|
|
@ -16,19 +16,6 @@
|
|||||||
{{ __('Dashboard') }}
|
{{ __('Dashboard') }}
|
||||||
</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.users')" :active="request()->routeIs('dashboard.users')">
|
|
||||||
{{ __('Usuarios') }}
|
|
||||||
</x-nav-link>
|
|
||||||
</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>
|
||||||
|
|
||||||
<!-- Settings Dropdown -->
|
<!-- Settings Dropdown -->
|
||||||
|
@ -3,30 +3,14 @@
|
|||||||
use App\Http\Controllers\ProfileController;
|
use App\Http\Controllers\ProfileController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\Fault;
|
|
||||||
|
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('home');
|
return view('home');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/dashboard', function () {
|
Route::get('/dashboard', function () {
|
||||||
$users = \App\Models\User::all();
|
return view('dashboard');
|
||||||
return view('dashboard.index', compact('users'));
|
|
||||||
})->middleware(['auth', 'verified'])->name('dashboard');
|
})->middleware(['auth', 'verified'])->name('dashboard');
|
||||||
|
|
||||||
// Subroute for users under /dashboard/users
|
|
||||||
Route::get('/dashboard/users', function () {
|
|
||||||
$users = \App\Models\User::all();
|
|
||||||
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::middleware('auth')->group(function () {
|
||||||
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
||||||
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
||||||
|
Loading…
Reference in New Issue
Block a user