añadir nuevas funcionalidades
This commit is contained in:
@@ -47,24 +47,24 @@ class ProjectController extends Controller
|
|||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
'description' => 'required|string',
|
'description' => 'nullable|string',
|
||||||
'status' => 'required|in:active,inactive',
|
'status' => 'required|in:Activo,Inactivo',
|
||||||
'team' => 'sometimes|array',
|
//'team' => 'sometimes|array',
|
||||||
'team.*' => 'exists:users,id',
|
//'team.*' => 'exists:users,id',
|
||||||
'project_image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
|
'project_image' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
'address' => 'nullable|string|max:255',
|
'address' => 'nullable|string|max:255',
|
||||||
'province' => 'nullable|string|max:100',
|
'province' => 'nullable|string|max:100',
|
||||||
'country' => 'nullable|string|size:2',
|
//'country' => 'nullable|string|size:2',
|
||||||
'postal_code' => 'nullable|string|max:10',
|
'postal_code' => 'nullable|string|max:10',
|
||||||
'latitude' => 'required|numeric|between:-90,90',
|
'latitude' => 'required|numeric|between:-90,90',
|
||||||
'longitude' => 'required|numeric|between:-180,180',
|
'longitude' => 'required|numeric|between:-180,180',
|
||||||
'icon' => 'nullable|in:'.implode(',', config('project.icons')),
|
//'icon' => 'nullable|in:'.implode(',', config('project.icons')),
|
||||||
'start_date' => 'nullable|date',
|
'start_date' => 'nullable|date',
|
||||||
'deadline' => 'nullable|date|after:start_date',
|
'deadline' => 'nullable|date|after:start_date',
|
||||||
'categories' => 'array|exists:categories,id',
|
'categories' => 'nullable|array|exists:categories,id',
|
||||||
//'categories' => 'required|array',
|
//'categories' => 'required|array',
|
||||||
'categories.*' => 'exists:categories,id',
|
//'categories.*' => 'exists:categories,id',
|
||||||
'documents.*' => 'file|max:5120|mimes:pdf,docx,xlsx,jpg,png'
|
//'documents.*' => 'file|max:5120|mimes:pdf,docx,xlsx,jpg,png'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
@@ -98,12 +98,10 @@ class ProjectController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('projects.show', $project)
|
return redirect()->route('projects.show', $project)->with('success', 'Proyecto creado exitosamente');
|
||||||
->with('success', 'Proyecto creado exitosamente');
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->withInput()
|
return back()->withInput()->with('error', 'Error al crear el proyecto: ' . $e->getMessage());
|
||||||
->with('error', 'Error al crear el proyecto: ' . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,14 @@ namespace App\Http\Controllers;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use App\Http\Requests\UpdateUserRequest;
|
use App\Rules\PasswordRule;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
@@ -13,7 +20,7 @@ class UserController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', User::class);
|
$this->authorize('viewAny', User::class);
|
||||||
$users = User::with('roles')->paginate(10);
|
$users = User::paginate(10);
|
||||||
return view('users.index', compact('users'));
|
return view('users.index', compact('users'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,24 +34,60 @@ class UserController extends Controller
|
|||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$this->authorize('create', User::class);
|
$this->authorize('create', User::class);
|
||||||
|
try {
|
||||||
$data = $request->validate([
|
// Validación de datos
|
||||||
'name' => 'required|string|max:255',
|
$validated = $request->validate([
|
||||||
'email' => 'required|email|unique:users',
|
'title' => 'nullable|string|max:10',
|
||||||
'password' => 'required|min:8|confirmed',
|
'first_name' => 'required|string|max:50',
|
||||||
'roles' => 'array'
|
'last_name' => 'required|string|max:50',
|
||||||
]);
|
'username' => 'required|string|unique:users|max:30',
|
||||||
|
'password' => ['required',
|
||||||
$user = User::create([
|
new PasswordRule(
|
||||||
'name' => $data['name'],
|
minLength: 12,
|
||||||
'email' => $data['email'],
|
requireUppercase: true,
|
||||||
'password' => Hash::make($data['password'])
|
requireNumeric: true,
|
||||||
]);
|
requireSpecialCharacter: true,
|
||||||
|
//uncompromised: true, // Verificar contra Have I Been Pwned
|
||||||
$user->syncRoles($data['roles'] ?? []);
|
//requireLetters: true
|
||||||
|
),
|
||||||
return redirect()->route('users.index')
|
Password::defaults()->mixedCase()->numbers()->symbols()
|
||||||
->with('success', 'Usuario creado exitosamente');
|
->uncompromised(3) // Número mínimo de apariciones en brechas
|
||||||
|
],
|
||||||
|
'start_date' => 'nullable|date',
|
||||||
|
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||||
|
'email' => 'required|email|unique:users',
|
||||||
|
'phone' => 'nullable|string|max:20',
|
||||||
|
'address' => 'nullable|string|max:255'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Creación del usuario
|
||||||
|
$user = User::create([
|
||||||
|
'title' => $validated['title'],
|
||||||
|
'first_name' => $validated['first_name'],
|
||||||
|
'last_name' => $validated['last_name'],
|
||||||
|
'username' => $validated['username'],
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'phone' => $validated['phone'],
|
||||||
|
'address' => $validated['address'],
|
||||||
|
'access_start' => $validated['start_date'],
|
||||||
|
'access_end' => $validated['end_date'],
|
||||||
|
'is_active' => true
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->hasFile('photo')) {
|
||||||
|
$path = $request->file('photo')->store('public/photos');
|
||||||
|
$user->profile_photo_path = basename($path);
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Asignación de roles (opcional, usando Spatie Permissions)
|
||||||
|
// $user->assignRole('user');
|
||||||
|
|
||||||
|
return redirect()->route('users.index')->with('success', 'Usuario creado exitosamente.')->with('temp_password', $validated['password']);;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->withInput()->with('error', 'Error al crear el usuario: ' . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(User $user)
|
public function edit(User $user)
|
||||||
@@ -52,17 +95,114 @@ class UserController extends Controller
|
|||||||
$this->authorize('update', $user);
|
$this->authorize('update', $user);
|
||||||
$roles = Role::all();
|
$roles = Role::all();
|
||||||
$userRoles = $user->roles->pluck('id')->toArray();
|
$userRoles = $user->roles->pluck('id')->toArray();
|
||||||
|
return view('users.create', compact('user', 'roles', 'userRoles'));
|
||||||
return view('users.edit', compact('user', 'roles', 'userRoles'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(UpdateUserRequest $request, User $user)
|
public function update(Request $request, User $user)
|
||||||
{
|
{
|
||||||
$user->update($request->validated());
|
try {
|
||||||
$user->syncRoles($request->roles);
|
// Validación de datos
|
||||||
|
$validated = $request->validate([
|
||||||
return redirect()->route('users.index')
|
'title' => 'nullable|string|max:10',
|
||||||
->with('success', 'Usuario actualizado correctamente');
|
'first_name' => 'required|string|max:50',
|
||||||
|
'last_name' => 'required|string|max:50',
|
||||||
|
'username' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:30',
|
||||||
|
Rule::unique('users')->ignore($user->id)
|
||||||
|
],
|
||||||
|
'password' => [
|
||||||
|
'nullable',
|
||||||
|
Password::min(12)
|
||||||
|
->mixedCase()
|
||||||
|
->numbers()
|
||||||
|
->symbols()
|
||||||
|
->uncompromised(3)
|
||||||
|
],
|
||||||
|
'start_date' => 'nullable|date',
|
||||||
|
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'email',
|
||||||
|
Rule::unique('users')->ignore($user->id)
|
||||||
|
],
|
||||||
|
'phone' => 'nullable|string|max:20',
|
||||||
|
'address' => 'nullable|string|max:255'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Preparar datos para actualización
|
||||||
|
$updateData = [
|
||||||
|
'title' => $validated['title'],
|
||||||
|
'first_name' => $validated['first_name'],
|
||||||
|
'last_name' => $validated['last_name'],
|
||||||
|
'username' => $validated['username'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'phone' => $validated['phone'],
|
||||||
|
'address' => $validated['address'],
|
||||||
|
'access_start' => $validated['start_date'],
|
||||||
|
'access_end' => $validated['end_date'],
|
||||||
|
'is_active' => $request->has('is_active') // Si usas un checkbox
|
||||||
|
];
|
||||||
|
|
||||||
|
// Actualizar contraseña solo si se proporciona
|
||||||
|
if (!empty($validated['password'])) {
|
||||||
|
$updateData['password'] = Hash::make($validated['password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('photo')) {
|
||||||
|
// Eliminar foto anterior si existe
|
||||||
|
if ($user->prfile_photo_path) {
|
||||||
|
Storage::delete('public/photos/'.$user->profile_photo_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $request->file('photo')->store('public/photos');
|
||||||
|
$user->update(['profile_photo_path' => basename($path)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualizar el usuario
|
||||||
|
$user->update($updateData);
|
||||||
|
|
||||||
|
// Redireccionar con mensaje de éxito
|
||||||
|
return redirect()->route('users.show', $user)
|
||||||
|
->with('success', 'Usuario actualizado exitosamente');
|
||||||
|
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
// Redireccionar con errores de validación
|
||||||
|
return redirect()->back()->withErrors($e->validator)->withInput();
|
||||||
|
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
// Manejar errores de base de datos
|
||||||
|
$errorCode = $e->errorInfo[1];
|
||||||
|
$errorMessage = 'Error al actualizar el usuario: ';
|
||||||
|
|
||||||
|
if ($errorCode == 1062) {
|
||||||
|
$errorMessage .= 'El nombre de usuario o correo electrónico ya está en uso';
|
||||||
|
} else {
|
||||||
|
$errorMessage .= 'Error en la base de datos';
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::error("Error actualizando usuario ID {$user->id}: " . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', $errorMessage)->withInput();
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Manejar otros errores
|
||||||
|
Log::error("Error general actualizando usuario ID {$user->id}: " . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'Ocurrió un error inesperado al actualizar el usuario')->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(User $user)
|
||||||
|
{
|
||||||
|
$previousUser = User::where('id', '<', $user->id)->latest('id')->first();
|
||||||
|
$nextUser = User::where('id', '>', $user->id)->oldest('id')->first();
|
||||||
|
|
||||||
|
return view('users.show', [
|
||||||
|
'user' => $user,
|
||||||
|
'previousUser' => $previousUser,
|
||||||
|
'nextUser' => $nextUser,
|
||||||
|
'permissionGroups' => Permission::all()->groupBy('group')
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePassword(Request $request, User $user)
|
public function updatePassword(Request $request, User $user)
|
||||||
|
|||||||
66
app/Livewire/CountrySelect.php
Normal file
66
app/Livewire/CountrySelect.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class CountrySelect extends Component
|
||||||
|
{
|
||||||
|
public $selectedCountry;
|
||||||
|
public $countrySearch = '';
|
||||||
|
public $search = '';
|
||||||
|
public $isOpen = false;
|
||||||
|
public $initialCountry;
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'selectedCountry' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount($initialCountry = null)
|
||||||
|
{
|
||||||
|
$this->selectedCountry = $initialCountry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectCountry($code)
|
||||||
|
{
|
||||||
|
$this->selectedCountry = $code;
|
||||||
|
$this->isOpen = false;
|
||||||
|
$this->search = ''; // Limpiar la búsqueda al seleccionar
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$countries = collect(config('countries'))
|
||||||
|
->when($this->search, function($collection) {
|
||||||
|
// Corregimos el filtrado aquí
|
||||||
|
return $collection->filter(function($name, $code) {
|
||||||
|
$searchLower = strtolower($this->search);
|
||||||
|
$nameLower = strtolower($name);
|
||||||
|
$codeLower = strtolower($code);
|
||||||
|
|
||||||
|
return str_contains($nameLower, $searchLower) ||
|
||||||
|
str_contains($codeLower, $searchLower);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return view('livewire.country-select', compact('countries'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formattedCountry($code, $name)
|
||||||
|
{
|
||||||
|
return $this->getFlagEmoji($code).' '.$name.' ('.strtoupper($code).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFlagEmoji($countryCode)
|
||||||
|
{
|
||||||
|
$countryCode = strtoupper($countryCode);
|
||||||
|
$flagOffset = 0x1F1E6;
|
||||||
|
$asciiOffset = 0x41;
|
||||||
|
|
||||||
|
$firstChar = ord($countryCode[0]) - $asciiOffset + $flagOffset;
|
||||||
|
$secondChar = ord($countryCode[1]) - $asciiOffset + $flagOffset;
|
||||||
|
|
||||||
|
return mb_convert_encoding('&#'.intval($firstChar).';', 'UTF-8', 'HTML-ENTITIES')
|
||||||
|
. mb_convert_encoding('&#'.intval($secondChar).';', 'UTF-8', 'HTML-ENTITIES');
|
||||||
|
}
|
||||||
|
}
|
||||||
79
app/Livewire/ImageUploader.php
Normal file
79
app/Livewire/ImageUploader.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ImageUploader extends Component
|
||||||
|
{
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
|
public $photo;
|
||||||
|
public $currentImage;
|
||||||
|
public $fieldName;
|
||||||
|
public $placeholder;
|
||||||
|
public $storagePath = 'tmp/uploads';
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'photo' => 'nullable|image|max:2048', // 2MB Max
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount($fieldName = 'photo', $currentImage = null, $placeholder = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
$this->currentImage = $currentImage;
|
||||||
|
$this->placeholder = $placeholder ?? asset('images/default-avatar.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedPhoto()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'photo' => 'image|max:2048', // 2MB Max
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removePhoto()
|
||||||
|
{
|
||||||
|
$this->photo = null;
|
||||||
|
$this->currentImage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
|
||||||
|
if ($this->photo) {
|
||||||
|
$path = $this->photo->store($this->storagePath);
|
||||||
|
|
||||||
|
if ($this->model) {
|
||||||
|
// Eliminar imagen anterior si existe
|
||||||
|
if ($this->model->{$this->fieldName}) {
|
||||||
|
Storage::delete($this->model->{$this->fieldName});
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->model->{$this->fieldName} = $path;
|
||||||
|
$this->model->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->currentUrl = Storage::url($path);
|
||||||
|
$this->showSavedMessage = true;
|
||||||
|
$this->photo = null; // Limpiar el input de subida
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCurrentImageUrl()
|
||||||
|
{
|
||||||
|
if ($this->model && $this->model->{$this->fieldName}) {
|
||||||
|
return Storage::url($this->model->{$this->fieldName});
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.image-uploader');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,7 +65,7 @@ class ProjectShow extends Component
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->reset('folderName');
|
$this->reset('folderName');
|
||||||
$this->project->load('rootFolders'); // Recargar carpetas raíz
|
$this->project->load('rootFolders'); // Recargar carpetas raíz
|
||||||
if ($this->currentFolder) {
|
if ($this->currentFolder) {
|
||||||
$this->currentFolder->load('children'); // Recargar hijos si está en una subcarpeta
|
$this->currentFolder->load('children'); // Recargar hijos si está en una subcarpeta
|
||||||
}
|
}
|
||||||
@@ -118,9 +118,6 @@ class ProjectShow extends Component
|
|||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.project-show')
|
return view('livewire.project-show');
|
||||||
->layout('layouts.livewire-app', [
|
|
||||||
'title' => $this->project->name
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
81
app/Livewire/UserPhotoUpload.php
Normal file
81
app/Livewire/UserPhotoUpload.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class UserPhotoUpload extends Component
|
||||||
|
{
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
|
public $photo;
|
||||||
|
public $existingPhoto;
|
||||||
|
public $tempPhoto;
|
||||||
|
public $userId;
|
||||||
|
|
||||||
|
protected $listeners = ['photoUpdated' => 'refreshPhoto'];
|
||||||
|
|
||||||
|
public function mount($existingPhoto = null, $userId = null)
|
||||||
|
{
|
||||||
|
$this->existingPhoto = $existingPhoto;
|
||||||
|
$this->userId = $userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadPhoto()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'photo' => 'image|max:2048|mimes:jpg,png,jpeg,gif',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->tempPhoto = $this->photo->temporaryUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedPhoto()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'photo' => 'image|max:2048|mimes:jpg,png,jpeg,gif',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->tempPhoto = $this->photo->temporaryUrl();
|
||||||
|
|
||||||
|
// Emitir evento con la foto temporal
|
||||||
|
$this->emit('photoUploaded', $this->photo->getRealPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removePhoto()
|
||||||
|
{
|
||||||
|
$this->reset('photo', 'tempPhoto');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deletePhoto()
|
||||||
|
{
|
||||||
|
if ($this->existingPhoto) {
|
||||||
|
Storage::delete('public/photos/' . $this->existingPhoto);
|
||||||
|
|
||||||
|
if ($this->userId) {
|
||||||
|
$user = User::find($this->userId);
|
||||||
|
$user->update(['profile_photo_path' => null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->existingPhoto = null;
|
||||||
|
$this->emit('photoDeleted');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refreshPhoto()
|
||||||
|
{
|
||||||
|
$this->existingPhoto = User::find($this->userId)->profile_photo_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.user-photo-upload', [
|
||||||
|
//'photo' => $this->photo,
|
||||||
|
'tempPhoto' => $this->tempPhoto,
|
||||||
|
'existingPhoto' => $this->existingPhoto,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
109
app/Livewire/UserTable.php
Normal file
109
app/Livewire/UserTable.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithPagination;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class UserTable extends Component
|
||||||
|
{
|
||||||
|
use WithPagination;
|
||||||
|
|
||||||
|
public $sortField = 'first_name';
|
||||||
|
public $sortDirection = 'asc';
|
||||||
|
|
||||||
|
public $columns = [
|
||||||
|
'full_name' => true,
|
||||||
|
'is_active' => true,
|
||||||
|
'username' => true,
|
||||||
|
'email' => true,
|
||||||
|
'phone' => false,
|
||||||
|
'access_start' => false,
|
||||||
|
'created_at' => false,
|
||||||
|
'is_active' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
public $filters = [
|
||||||
|
'full_name' => '',
|
||||||
|
'is_active' => '',
|
||||||
|
'username' => '',
|
||||||
|
'email' => '',
|
||||||
|
'phone' => '',
|
||||||
|
'access_start' => '',
|
||||||
|
'created_at' => ''
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $queryString = [
|
||||||
|
'filters' => ['except' => ''],
|
||||||
|
'columns' => ['except' => '']
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
// Recuperar preferencias de columnas de la sesión
|
||||||
|
$this->columns = session('user_columns', $this->columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedColumns()
|
||||||
|
{
|
||||||
|
// Guardar preferencias en sesión
|
||||||
|
session(['user_columns' => $this->columns]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sortBy($field)
|
||||||
|
{
|
||||||
|
if ($this->sortField === $field) {
|
||||||
|
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||||
|
} else {
|
||||||
|
$this->sortDirection = 'asc';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sortField = $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$users = User::query()
|
||||||
|
->when($this->filters['full_name'], fn($q, $search) =>
|
||||||
|
$q->whereRaw("CONCAT(title, ' ', first_name, ' ', last_name) LIKE ?", ["%$search%"]))
|
||||||
|
->when($this->sortField === 'full_name', fn($q) =>
|
||||||
|
$q->orderByRaw("CONCAT(title, ' ', first_name, ' ', last_name) " . $this->sortDirection)
|
||||||
|
)
|
||||||
|
->when($this->sortField === 'created_at', fn($q) =>
|
||||||
|
$q->orderBy('created_at', $this->sortDirection)
|
||||||
|
)
|
||||||
|
->when($this->sortField === 'access_start', fn($q) =>
|
||||||
|
$q->orderBy('access_start', $this->sortDirection)
|
||||||
|
)
|
||||||
|
->when(in_array($this->sortField, ['username', 'email', 'phone']), fn($q) =>
|
||||||
|
$q->orderBy($this->sortField, $this->sortDirection)
|
||||||
|
)
|
||||||
|
->when($this->filters['full_name'], fn($q, $search) =>
|
||||||
|
$q->whereRaw("CONCAT(title, ' ', first_name, ' ', last_name) LIKE ?", ["%$search%"]))
|
||||||
|
->when($this->filters['username'], fn($q, $search) =>
|
||||||
|
$q->where('username', 'LIKE', "%$search%"))
|
||||||
|
->when($this->filters['email'], fn($q, $search) =>
|
||||||
|
$q->where('email', 'LIKE', "%$search%"))
|
||||||
|
->when($this->filters['phone'], fn($q, $search) =>
|
||||||
|
$q->where('phone', 'LIKE', "%$search%"))
|
||||||
|
->when($this->filters['access_start'], fn($q, $date) =>
|
||||||
|
$q->whereDate('access_start', $date))
|
||||||
|
->when($this->filters['created_at'], fn($q, $date) =>
|
||||||
|
$q->whereDate('created_at', $date))
|
||||||
|
->paginate(10);
|
||||||
|
|
||||||
|
return view('livewire.user-table', [
|
||||||
|
'users' => $users,
|
||||||
|
'available_columns' => [
|
||||||
|
'full_name' => 'Nombre Completo',
|
||||||
|
'username' => 'Usuario',
|
||||||
|
'email' => 'Correo',
|
||||||
|
'phone' => 'Teléfono',
|
||||||
|
'access_start' => 'Fecha de acceso',
|
||||||
|
'created_at' => 'Fecha creación',
|
||||||
|
'is_active' => 'Estado'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
@@ -21,9 +22,18 @@ class User extends Authenticatable
|
|||||||
* @var list<string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'title',
|
||||||
|
'first_name',
|
||||||
|
'last_name',
|
||||||
|
'username',
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
|
'phone',
|
||||||
|
'address',
|
||||||
|
'access_start',
|
||||||
|
'access_end',
|
||||||
|
'is_active',
|
||||||
|
'profile_photo_path',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,26 +49,25 @@ class User extends Authenticatable
|
|||||||
/**
|
/**
|
||||||
* Get the attributes that should be cast.
|
* Get the attributes that should be cast.
|
||||||
*
|
*
|
||||||
* @return array<string, string>
|
* @var list<string>
|
||||||
*/
|
*/
|
||||||
protected function casts(): array
|
protected $casts = [
|
||||||
{
|
'email_verified_at' => 'datetime',
|
||||||
return [
|
'access_start' => 'date',
|
||||||
'email_verified_at' => 'datetime',
|
'access_end' => 'date',
|
||||||
'password' => 'hashed',
|
'is_active' => 'boolean'
|
||||||
'is_protected' => 'boolean',
|
];
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user's initials
|
* Get the user's initials
|
||||||
*/
|
*/
|
||||||
public function initials(): string
|
public function initials(): string
|
||||||
{
|
{
|
||||||
return Str::of($this->name)
|
/*return Str::of($this->name)
|
||||||
->explode(' ')
|
->explode(' ')
|
||||||
->map(fn (string $name) => Str::of($name)->substr(0, 1))
|
->map(fn (string $name) => Str::of($name)->substr(0, 1))
|
||||||
->implode('');
|
->implode('');*/
|
||||||
|
return Str::of('');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function groups()
|
public function groups()
|
||||||
@@ -89,5 +98,16 @@ class User extends Authenticatable
|
|||||||
return $group->hasAnyPermission($permissions);
|
return $group->hasAnyPermission($permissions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFullNameAttribute()
|
||||||
|
{
|
||||||
|
return "{$this->title} {$this->first_name} {$this->last_name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accesor para la URL completa
|
||||||
|
public function getProfilePhotoUrlAttribute()
|
||||||
|
{
|
||||||
|
return $this->profile_photo ? Storage::url($this->profile_photo) : asset('images/default-user.png');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
69
app/Rules/PasswordRule.php
Normal file
69
app/Rules/PasswordRule.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Rules;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class PasswordRule implements ValidationRule
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $minLength;
|
||||||
|
protected $requireUppercase;
|
||||||
|
protected $requireNumeric;
|
||||||
|
protected $requireSpecialCharacter;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
int $minLength = 8,
|
||||||
|
bool $requireUppercase = true,
|
||||||
|
bool $requireNumeric = true,
|
||||||
|
bool $requireSpecialCharacter = true
|
||||||
|
) {
|
||||||
|
$this->minLength = $minLength;
|
||||||
|
$this->requireUppercase = $requireUppercase;
|
||||||
|
$this->requireNumeric = $requireNumeric;
|
||||||
|
$this->requireSpecialCharacter = $requireSpecialCharacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the validation rule.
|
||||||
|
*
|
||||||
|
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||||
|
*/
|
||||||
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function passes($attribute, $value)
|
||||||
|
{
|
||||||
|
$passes = true;
|
||||||
|
|
||||||
|
if (strlen($value) < $this->minLength) {
|
||||||
|
$passes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->requireUppercase && !preg_match('/[A-Z]/', $value)) {
|
||||||
|
$passes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->requireNumeric && !preg_match('/[0-9]/', $value)) {
|
||||||
|
$passes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->requireSpecialCharacter && !preg_match('/[\W_]/', $value)) {
|
||||||
|
$passes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $passes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function message()
|
||||||
|
{
|
||||||
|
return 'La contraseña debe contener al menos '.$this->minLength.' caracteres'.
|
||||||
|
($this->requireUppercase ? ', una mayúscula' : '').
|
||||||
|
($this->requireNumeric ? ', un número' : '').
|
||||||
|
($this->requireSpecialCharacter ? ' y un carácter especial' : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,253 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ES' => 'España',
|
'AD' => 'Andorra',
|
||||||
'FR' => 'Francia',
|
'AE' => 'United Arab Emirates',
|
||||||
|
'AF' => 'Afghanistan',
|
||||||
|
'AG' => 'Antigua and Barbuda',
|
||||||
|
'AI' => 'Anguilla',
|
||||||
|
'AL' => 'Albania',
|
||||||
|
'AM' => 'Armenia',
|
||||||
|
'AO' => 'Angola',
|
||||||
|
'AQ' => 'Antarctica',
|
||||||
|
'AR' => 'Argentina',
|
||||||
|
'AS' => 'American Samoa',
|
||||||
|
'AT' => 'Austria',
|
||||||
|
'AU' => 'Australia',
|
||||||
|
'AW' => 'Aruba',
|
||||||
|
'AX' => 'Åland Islands',
|
||||||
|
'AZ' => 'Azerbaijan',
|
||||||
|
'BA' => 'Bosnia and Herzegovina',
|
||||||
|
'BB' => 'Barbados',
|
||||||
|
'BD' => 'Bangladesh',
|
||||||
|
'BE' => 'Belgium',
|
||||||
|
'BF' => 'Burkina Faso',
|
||||||
|
'BG' => 'Bulgaria',
|
||||||
|
'BH' => 'Bahrain',
|
||||||
|
'BI' => 'Burundi',
|
||||||
|
'BJ' => 'Benin',
|
||||||
|
'BL' => 'Saint Barthélemy',
|
||||||
|
'BM' => 'Bermuda',
|
||||||
|
'BN' => 'Brunei Darussalam',
|
||||||
|
'BO' => 'Bolivia, Plurinational State of',
|
||||||
|
'BQ' => 'Bonaire, Sint Eustatius and Saba',
|
||||||
|
'BR' => 'Brazil',
|
||||||
|
'BS' => 'Bahamas',
|
||||||
|
'BT' => 'Bhutan',
|
||||||
|
'BV' => 'Bouvet Island',
|
||||||
|
'BW' => 'Botswana',
|
||||||
|
'BY' => 'Belarus',
|
||||||
|
'BZ' => 'Belize',
|
||||||
|
'CA' => 'Canada',
|
||||||
|
'CC' => 'Cocos (Keeling) Islands',
|
||||||
|
'CD' => 'Congo, the Democratic Republic of the',
|
||||||
|
'CF' => 'Central African Republic',
|
||||||
|
'CG' => 'Congo',
|
||||||
|
'CH' => 'Switzerland',
|
||||||
|
'CI' => "Côte d'Ivoire",
|
||||||
|
'CK' => 'Cook Islands',
|
||||||
|
'CL' => 'Chile',
|
||||||
|
'CM' => 'Cameroon',
|
||||||
|
'CN' => 'China',
|
||||||
|
'CO' => 'Colombia',
|
||||||
|
'CR' => 'Costa Rica',
|
||||||
|
'CU' => 'Cuba',
|
||||||
|
'CV' => 'Cape Verde',
|
||||||
|
'CW' => 'Curaçao',
|
||||||
|
'CX' => 'Christmas Island',
|
||||||
|
'CY' => 'Cyprus',
|
||||||
|
'CZ' => 'Czech Republic',
|
||||||
|
'DE' => 'Germany',
|
||||||
|
'DJ' => 'Djibouti',
|
||||||
|
'DK' => 'Denmark',
|
||||||
|
'DM' => 'Dominica',
|
||||||
|
'DO' => 'Dominican Republic',
|
||||||
|
'DZ' => 'Algeria',
|
||||||
|
'EC' => 'Ecuador',
|
||||||
|
'EE' => 'Estonia',
|
||||||
|
'EG' => 'Egypt',
|
||||||
|
'EH' => 'Western Sahara',
|
||||||
|
'ER' => 'Eritrea',
|
||||||
|
'ES' => 'Spain',
|
||||||
|
'ET' => 'Ethiopia',
|
||||||
|
'FI' => 'Finland',
|
||||||
|
'FJ' => 'Fiji',
|
||||||
|
'FK' => 'Falkland Islands (Malvinas)',
|
||||||
|
'FM' => 'Micronesia, Federated States of',
|
||||||
|
'FO' => 'Faroe Islands',
|
||||||
|
'FR' => 'France',
|
||||||
|
'GA' => 'Gabon',
|
||||||
|
'GB' => 'United Kingdom',
|
||||||
|
'GD' => 'Grenada',
|
||||||
|
'GE' => 'Georgia',
|
||||||
|
'GF' => 'French Guiana',
|
||||||
|
'GG' => 'Guernsey',
|
||||||
|
'GH' => 'Ghana',
|
||||||
|
'GI' => 'Gibraltar',
|
||||||
|
'GL' => 'Greenland',
|
||||||
|
'GM' => 'Gambia',
|
||||||
|
'GN' => 'Guinea',
|
||||||
|
'GP' => 'Guadeloupe',
|
||||||
|
'GQ' => 'Equatorial Guinea',
|
||||||
|
'GR' => 'Greece',
|
||||||
|
'GS' => 'South Georgia and the South Sandwich Islands',
|
||||||
|
'GT' => 'Guatemala',
|
||||||
|
'GU' => 'Guam',
|
||||||
|
'GW' => 'Guinea-Bissau',
|
||||||
|
'GY' => 'Guyana',
|
||||||
|
'HK' => 'Hong Kong',
|
||||||
|
'HM' => 'Heard Island and McDonald Islands',
|
||||||
|
'HN' => 'Honduras',
|
||||||
|
'HR' => 'Croatia',
|
||||||
|
'HT' => 'Haiti',
|
||||||
|
'HU' => 'Hungary',
|
||||||
|
'ID' => 'Indonesia',
|
||||||
|
'IE' => 'Ireland',
|
||||||
|
'IL' => 'Israel',
|
||||||
|
'IM' => 'Isle of Man',
|
||||||
|
'IN' => 'India',
|
||||||
|
'IO' => 'British Indian Ocean Territory',
|
||||||
|
'IQ' => 'Iraq',
|
||||||
|
'IR' => 'Iran, Islamic Republic of',
|
||||||
|
'IS' => 'Iceland',
|
||||||
|
'IT' => 'Italy',
|
||||||
|
'JE' => 'Jersey',
|
||||||
|
'JM' => 'Jamaica',
|
||||||
|
'JO' => 'Jordan',
|
||||||
|
'JP' => 'Japan',
|
||||||
|
'KE' => 'Kenya',
|
||||||
|
'KG' => 'Kyrgyzstan',
|
||||||
|
'KH' => 'Cambodia',
|
||||||
|
'KI' => 'Kiribati',
|
||||||
|
'KM' => 'Comoros',
|
||||||
|
'KN' => 'Saint Kitts and Nevis',
|
||||||
|
'KP' => "Korea, Democratic People's Republic of",
|
||||||
|
'KR' => 'Korea, Republic of',
|
||||||
|
'KW' => 'Kuwait',
|
||||||
|
'KY' => 'Cayman Islands',
|
||||||
|
'KZ' => 'Kazakhstan',
|
||||||
|
'LA' => "Lao People's Democratic Republic",
|
||||||
|
'LB' => 'Lebanon',
|
||||||
|
'LC' => 'Saint Lucia',
|
||||||
|
'LI' => 'Liechtenstein',
|
||||||
|
'LK' => 'Sri Lanka',
|
||||||
|
'LR' => 'Liberia',
|
||||||
|
'LS' => 'Lesotho',
|
||||||
|
'LT' => 'Lithuania',
|
||||||
|
'LU' => 'Luxembourg',
|
||||||
|
'LV' => 'Latvia',
|
||||||
|
'LY' => 'Libyan Arab Jamahiriya',
|
||||||
|
'MA' => 'Morocco',
|
||||||
|
'MC' => 'Monaco',
|
||||||
|
'MD' => 'Moldova, Republic of',
|
||||||
|
'ME' => 'Montenegro',
|
||||||
|
'MF' => 'Saint Martin (French part)',
|
||||||
|
'MG' => 'Madagascar',
|
||||||
|
'MH' => 'Marshall Islands',
|
||||||
|
'MK' => 'Macedonia, the former Yugoslav Republic of',
|
||||||
|
'ML' => 'Mali',
|
||||||
|
'MM' => 'Myanmar',
|
||||||
|
'MN' => 'Mongolia',
|
||||||
|
'MO' => 'Macao',
|
||||||
|
'MP' => 'Northern Mariana Islands',
|
||||||
|
'MQ' => 'Martinique',
|
||||||
|
'MR' => 'Mauritania',
|
||||||
|
'MS' => 'Montserrat',
|
||||||
|
'MT' => 'Malta',
|
||||||
|
'MU' => 'Mauritius',
|
||||||
|
'MV' => 'Maldives',
|
||||||
|
'MW' => 'Malawi',
|
||||||
|
'MX' => 'Mexico',
|
||||||
|
'MY' => 'Malaysia',
|
||||||
|
'MZ' => 'Mozambique',
|
||||||
|
'NA' => 'Namibia',
|
||||||
|
'NC' => 'New Caledonia',
|
||||||
|
'NE' => 'Niger',
|
||||||
|
'NF' => 'Norfolk Island',
|
||||||
|
'NG' => 'Nigeria',
|
||||||
|
'NI' => 'Nicaragua',
|
||||||
|
'NL' => 'Netherlands',
|
||||||
|
'NO' => 'Norway',
|
||||||
|
'NP' => 'Nepal',
|
||||||
|
'NR' => 'Nauru',
|
||||||
|
'NU' => 'Niue',
|
||||||
|
'NZ' => 'New Zealand',
|
||||||
|
'OM' => 'Oman',
|
||||||
|
'PA' => 'Panama',
|
||||||
|
'PE' => 'Peru',
|
||||||
|
'PF' => 'French Polynesia',
|
||||||
|
'PG' => 'Papua New Guinea',
|
||||||
|
'PH' => 'Philippines',
|
||||||
|
'PK' => 'Pakistan',
|
||||||
|
'PL' => 'Poland',
|
||||||
|
'PM' => 'Saint Pierre and Miquelon',
|
||||||
|
'PN' => 'Pitcairn',
|
||||||
|
'PR' => 'Puerto Rico',
|
||||||
|
'PS' => 'Palestinian Territory, Occupied',
|
||||||
'PT' => 'Portugal',
|
'PT' => 'Portugal',
|
||||||
// ... resto de países
|
'PW' => 'Palau',
|
||||||
|
'PY' => 'Paraguay',
|
||||||
|
'QA' => 'Qatar',
|
||||||
|
'RE' => 'Réunion',
|
||||||
|
'RO' => 'Romania',
|
||||||
|
'RS' => 'Serbia',
|
||||||
|
'RU' => 'Russian Federation',
|
||||||
|
'RW' => 'Rwanda',
|
||||||
|
'SA' => 'Saudi Arabia',
|
||||||
|
'SB' => 'Solomon Islands',
|
||||||
|
'SC' => 'Seychelles',
|
||||||
|
'SD' => 'Sudan',
|
||||||
|
'SE' => 'Sweden',
|
||||||
|
'SG' => 'Singapore',
|
||||||
|
'SH' => 'Saint Helena, Ascension and Tristan da Cunha',
|
||||||
|
'SI' => 'Slovenia',
|
||||||
|
'SJ' => 'Svalbard and Jan Mayen',
|
||||||
|
'SK' => 'Slovakia',
|
||||||
|
'SL' => 'Sierra Leone',
|
||||||
|
'SM' => 'San Marino',
|
||||||
|
'SN' => 'Senegal',
|
||||||
|
'SO' => 'Somalia',
|
||||||
|
'SR' => 'Suriname',
|
||||||
|
'SS' => 'South Sudan',
|
||||||
|
'ST' => 'Sao Tome and Principe',
|
||||||
|
'SV' => 'El Salvador',
|
||||||
|
'SX' => 'Sint Maarten',
|
||||||
|
'SY' => 'Syrian Arab Republic',
|
||||||
|
'SZ' => 'Swaziland',
|
||||||
|
'TC' => 'Turks and Caicos Islands',
|
||||||
|
'TD' => 'Chad',
|
||||||
|
'TF' => 'French Southern Territories',
|
||||||
|
'TG' => 'Togo',
|
||||||
|
'TH' => 'Thailand',
|
||||||
|
'TJ' => 'Tajikistan',
|
||||||
|
'TK' => 'Tokelau',
|
||||||
|
'TL' => 'Timor-Leste',
|
||||||
|
'TM' => 'Turkmenistan',
|
||||||
|
'TN' => 'Tunisia',
|
||||||
|
'TO' => 'Tonga',
|
||||||
|
'TR' => 'Turkey',
|
||||||
|
'TT' => 'Trinidad and Tobago',
|
||||||
|
'TV' => 'Tuvalu',
|
||||||
|
'TW' => 'Taiwan, Province of China',
|
||||||
|
'TZ' => 'Tanzania, United Republic of',
|
||||||
|
'UA' => 'Ukraine',
|
||||||
|
'UG' => 'Uganda',
|
||||||
|
'UM' => 'United States Minor Outlying Islands',
|
||||||
|
'US' => 'United States',
|
||||||
|
'UY' => 'Uruguay',
|
||||||
|
'UZ' => 'Uzbekistan',
|
||||||
|
'VA' => 'Holy See (Vatican City State)',
|
||||||
|
'VC' => 'Saint Vincent and the Grenadines',
|
||||||
|
'VE' => 'Venezuela, Bolivarian Republic of',
|
||||||
|
'VG' => 'Virgin Islands, British',
|
||||||
|
'VI' => 'Virgin Islands, U.S.',
|
||||||
|
'VN' => 'Viet Nam',
|
||||||
|
'VU' => 'Vanuatu',
|
||||||
|
'WF' => 'Wallis and Futuna',
|
||||||
|
'WS' => 'Samoa',
|
||||||
|
'YE' => 'Yemen',
|
||||||
|
'YT' => 'Mayotte',
|
||||||
|
'ZA' => 'South Africa',
|
||||||
|
'ZM' => 'Zambia',
|
||||||
|
'ZW' => 'Zimbabwe',
|
||||||
];
|
];
|
||||||
51
database/migrations/2025_04_29_115501_update_users_table.php
Normal file
51
database/migrations/2025_04_29_115501_update_users_table.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?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::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('title')->nullable()->after('id');
|
||||||
|
$table->string('first_name')->after('title');
|
||||||
|
$table->string('last_name')->after('first_name');
|
||||||
|
$table->string('username')->unique()->after('last_name');
|
||||||
|
$table->date('access_start')->nullable()->after('password');
|
||||||
|
$table->date('access_end')->nullable()->after('access_start');
|
||||||
|
$table->string('phone')->nullable()->after('email');
|
||||||
|
$table->text('address')->nullable()->after('phone');
|
||||||
|
$table->boolean('is_active')->default(true)->after('address');
|
||||||
|
$table->string('profile_photo_path')->nullable();
|
||||||
|
|
||||||
|
// Eliminar campos no necesarios
|
||||||
|
$table->dropColumn('name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('title');
|
||||||
|
$table->dropColumn('first_name');
|
||||||
|
$table->dropColumn('last_name');
|
||||||
|
$table->dropColumn('username');
|
||||||
|
$table->dropColumn('access_start');
|
||||||
|
$table->dropColumn('access_end');
|
||||||
|
$table->dropColumn('phone');
|
||||||
|
$table->dropColumn('address');
|
||||||
|
$table->dropColumn('is_active');
|
||||||
|
$table->dropColumn('profile_photo_path ');
|
||||||
|
|
||||||
|
$table->string('name')->after('id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,9 +3,8 @@
|
|||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Spatie\Permission\Models\Permission;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@@ -16,10 +15,14 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
// User::factory(10)->create();
|
// User::factory(10)->create();
|
||||||
|
|
||||||
User::factory()->create([
|
User::create([
|
||||||
'name' => 'admin',
|
'first_name' => 'Administrador',
|
||||||
|
'last_name' => '',
|
||||||
|
'username' => 'admin',
|
||||||
'email' => 'admin@example.com',
|
'email' => 'admin@example.com',
|
||||||
'password' => '12345678',
|
'password' => Hash::make('12345678'),
|
||||||
|
'is_active' => true,
|
||||||
|
'access_start' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->call([
|
$this->call([
|
||||||
|
|||||||
@@ -56,15 +56,6 @@ class RolePermissionSeeder extends Seeder
|
|||||||
$adminRole->syncPermissions($allPermissions);
|
$adminRole->syncPermissions($allPermissions);
|
||||||
$adminRole->syncPermissions($permissions);
|
$adminRole->syncPermissions($permissions);
|
||||||
|
|
||||||
// Crear usuario admin si no existe
|
|
||||||
/*User::updateOrCreate(
|
|
||||||
['email' => env('ADMIN_EMAIL', 'admin@example.com')],
|
|
||||||
[
|
|
||||||
'name' => 'Administrador',
|
|
||||||
'password' => bcrypt(env('ADMIN_PASSWORD', 'password')),
|
|
||||||
'email_verified_at' => now()
|
|
||||||
]
|
|
||||||
)->assignRole($adminRole);*/
|
|
||||||
$adminEmail = env('ADMIN_EMAIL', 'admin@example.com');
|
$adminEmail = env('ADMIN_EMAIL', 'admin@example.com');
|
||||||
$user = User::where('email', $adminEmail)->first();
|
$user = User::where('email', $adminEmail)->first();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
@@ -75,9 +66,11 @@ class RolePermissionSeeder extends Seeder
|
|||||||
} else {
|
} else {
|
||||||
// Crear solo si no existe
|
// Crear solo si no existe
|
||||||
User::create([
|
User::create([
|
||||||
'name' => 'admin',
|
'first_name' => 'Administrador',
|
||||||
'email' => $adminEmail,
|
'username' => 'admin',
|
||||||
'password' => bcrypt(env('ADMIN_PASSWORD', '12345678')),
|
'email' => 'admin@example.com',
|
||||||
|
'password' => '12345678',
|
||||||
|
'is_active' => true,
|
||||||
'email_verified_at' => now()
|
'email_verified_at' => now()
|
||||||
])->assignRole($adminRole);
|
])->assignRole($adminRole);
|
||||||
}
|
}
|
||||||
|
|||||||
63
resources/views/livewire/country-select.blade.php
Normal file
63
resources/views/livewire/country-select.blade.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<!-- resources/views/livewire/country-select.blade.php -->
|
||||||
|
<div
|
||||||
|
x-data="{ open: @entangle('isOpen') }"
|
||||||
|
x-on:click.away="open = false"
|
||||||
|
class="relative"
|
||||||
|
>
|
||||||
|
<!-- Botón que activa el desplegable -->
|
||||||
|
<button
|
||||||
|
x-on:click="open = !open; $nextTick(() => { $refs.searchInput.focus() })"
|
||||||
|
type="button"
|
||||||
|
class="flex items-center justify-between w-[300px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
@if($selectedCountry && array_key_exists($selectedCountry, config('countries')))
|
||||||
|
{{ $this->formattedCountry($selectedCountry, config("countries.$selectedCountry")) }}
|
||||||
|
@else
|
||||||
|
Seleccione un país
|
||||||
|
@endif
|
||||||
|
</span>
|
||||||
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Desplegable -->
|
||||||
|
<div
|
||||||
|
x-show="open"
|
||||||
|
x-transition
|
||||||
|
class="absolute z-10 w-full mt-1 bg-white border rounded-md shadow-lg"
|
||||||
|
>
|
||||||
|
<!-- Input de búsqueda dentro del desplegable -->
|
||||||
|
<div class="p-2 border-b">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
wire:model.debounce.300ms="search"
|
||||||
|
placeholder="Buscar país..."
|
||||||
|
class="w-full p-2 border rounded-md"
|
||||||
|
x-ref="searchInput"
|
||||||
|
x-on:click.stop
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Lista de países -->
|
||||||
|
<div class="overflow-y-auto max-h-60">
|
||||||
|
@forelse($countries as $code => $name)
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="selectCountry('{{ $code }}')"
|
||||||
|
class="flex items-center w-full px-4 py-2 text-left hover:bg-gray-100"
|
||||||
|
>
|
||||||
|
{{ $this->formattedCountry($code, $name) }}
|
||||||
|
</button>
|
||||||
|
@empty
|
||||||
|
<div class="px-4 py-2 text-gray-500">
|
||||||
|
No se encontraron resultados
|
||||||
|
</div>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Input hidden para el formulario -->
|
||||||
|
<input type="hidden" name="country" value="{{ $selectedCountry }}">
|
||||||
|
</div>
|
||||||
44
resources/views/livewire/image-uploader.blade.php
Normal file
44
resources/views/livewire/image-uploader.blade.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<div>
|
||||||
|
<!-- Preview de imagen -->
|
||||||
|
<div class="relative mb-4">
|
||||||
|
<img src="{{ $photo ? $photo->temporaryUrl() : ($currentImage ?? $placeholder) }}"
|
||||||
|
alt="Preview"
|
||||||
|
class="w-32 h-32 rounded-full object-cover border-2 border-gray-300">
|
||||||
|
|
||||||
|
@if($photo || $currentImage)
|
||||||
|
<button type="button"
|
||||||
|
wire:click="removePhoto"
|
||||||
|
class="absolute top-0 right-0 bg-red-500 text-white rounded-full p-1 hover:bg-red-600 transition"
|
||||||
|
title="Eliminar foto">
|
||||||
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Input de archivo -->
|
||||||
|
<label class="cursor-pointer bg-white px-4 py-2 rounded-md shadow-sm border border-gray-300 hover:bg-gray-50 inline-block">
|
||||||
|
<span class="text-sm font-medium text-gray-700">
|
||||||
|
{{ $photo || $currentImage ? 'Cambiar imagen' : 'Seleccionar imagen' }}
|
||||||
|
</span>
|
||||||
|
<input type="file"
|
||||||
|
wire:model="photo"
|
||||||
|
class="hidden"
|
||||||
|
accept="image/*"
|
||||||
|
name="{{ $fieldName }}_input"> <!-- Input oculto para Livewire -->
|
||||||
|
|
||||||
|
<!-- Input real para el formulario -->
|
||||||
|
@if($photo)
|
||||||
|
<input type="hidden" name="{{ $fieldName }}" value="{{ $photo->getFilename() }}">
|
||||||
|
@elseif($currentImage)
|
||||||
|
<input type="hidden" name="{{ $fieldName }}" value="current">
|
||||||
|
@endif
|
||||||
|
</label>
|
||||||
|
|
||||||
|
@error('photo')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
|
||||||
|
<p class="mt-1 text-xs text-gray-500">PNG, JPG o JPEG (Max. 2MB)</p>
|
||||||
|
</div>
|
||||||
@@ -31,8 +31,7 @@
|
|||||||
<div class="p-4 border-b">
|
<div class="p-4 border-b">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h3 class="font-medium">Carpetas</h3>
|
<h3 class="font-medium">Carpetas</h3>
|
||||||
<button wire:click="createFolder"
|
<button wire:click="createFolder" class="p-1 text-gray-600 hover:bg-gray-100 rounded">
|
||||||
class="p-1 text-gray-600 hover:bg-gray-100 rounded">
|
|
||||||
<x-icons icon="plus" class="w-5 h-5" />
|
<x-icons icon="plus" class="w-5 h-5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,8 +66,7 @@
|
|||||||
multiple
|
multiple
|
||||||
class="hidden"
|
class="hidden"
|
||||||
id="file-upload">
|
id="file-upload">
|
||||||
<label for="file-upload"
|
<label for="file-upload" class="px-4 py-2 text-sm text-white bg-green-600 rounded-lg cursor-pointer hover:bg-green-700">
|
||||||
class="px-4 py-2 text-sm text-white bg-green-600 rounded-lg cursor-pointer hover:bg-green-700">
|
|
||||||
Subir Archivos
|
Subir Archivos
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -115,4 +113,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -15,7 +15,7 @@ new class extends Component {
|
|||||||
*/
|
*/
|
||||||
public function mount(): void
|
public function mount(): void
|
||||||
{
|
{
|
||||||
$this->name = Auth::user()->name;
|
$this->name = Auth::user()->first_name;
|
||||||
$this->email = Auth::user()->email;
|
$this->email = Auth::user()->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
96
resources/views/livewire/user-photo-upload.blade.php
Normal file
96
resources/views/livewire/user-photo-upload.blade.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<!-- resources/views/livewire/user-photo-upload.blade.php -->
|
||||||
|
|
||||||
|
<div class="mb-6" x-data="{ isUploading: false, previewUrl: '{{ $existingPhoto ? asset('storage/photos/'.$existingPhoto) : '' }}'}" }">
|
||||||
|
<!-- Foto existente -->
|
||||||
|
@if($existingPhoto)
|
||||||
|
<div class="mb-4 relative group">
|
||||||
|
<img src="{{ asset('storage/photos/' . $existingPhoto) }}"
|
||||||
|
alt="Foto actual"
|
||||||
|
class="w-32 h-32 rounded-full object-cover shadow-md">
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
wire:click="deletePhoto"
|
||||||
|
class="absolute top-0 right-0 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||||
|
title="Eliminar foto">
|
||||||
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Zona de carga -->
|
||||||
|
<div x-on:livewire-upload-start="isUploading = true"
|
||||||
|
x-on:livewire-upload-finish="isUploading = false"
|
||||||
|
x-on:livewire-upload-error="isUploading = false"
|
||||||
|
class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center cursor-pointer hover:border-blue-500 transition-colors">
|
||||||
|
|
||||||
|
<input type="file"
|
||||||
|
wire:model="photo"
|
||||||
|
id="photoInput"
|
||||||
|
class="hidden"
|
||||||
|
accept="image/*"
|
||||||
|
@if($existingPhoto) disabled @endif>
|
||||||
|
|
||||||
|
<label for="photoInput" class="cursor-pointer">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<svg class="mx-auto h-12 w-12 text-gray-400"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 48 48">
|
||||||
|
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<div class="text-sm text-gray-600">
|
||||||
|
<span class="font-medium text-blue-600">Sube una foto</span>
|
||||||
|
o arrastra y suelta
|
||||||
|
</div>
|
||||||
|
<div class="text-xs text-gray-500">
|
||||||
|
PNG, JPG, GIF hasta 2MB
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Vista previa temporal -->
|
||||||
|
@if($tempPhoto)
|
||||||
|
<div class="mt-4">
|
||||||
|
<img src="{{ $tempPhoto }}"
|
||||||
|
alt="Vista previa"
|
||||||
|
class="w-32 h-32 rounded-full object-cover mx-auto shadow-md">
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Loading state -->
|
||||||
|
<div x-show="isUploading" class="mt-2">
|
||||||
|
<div class="inline-flex items-center text-sm text-gray-500">
|
||||||
|
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-blue-500"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24">
|
||||||
|
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||||
|
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||||
|
</svg>
|
||||||
|
Subiendo...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botones de acción -->
|
||||||
|
@if($photo || $tempPhoto)
|
||||||
|
<div class="mt-4 flex justify-center gap-2">
|
||||||
|
<button type="button"
|
||||||
|
wire:click="removePhoto"
|
||||||
|
class="px-4 py-2 bg-red-100 text-red-700 rounded-md hover:bg-red-200 transition-colors">
|
||||||
|
Borrar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Mensajes de error -->
|
||||||
|
@error('photo')
|
||||||
|
<div class="mt-2 text-sm text-red-600">{{ $message }}</div>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
193
resources/views/livewire/user-table.blade.php
Normal file
193
resources/views/livewire/user-table.blade.php
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<div>
|
||||||
|
<!-- Controles de columnas -->
|
||||||
|
<div class="mb-4 flex items-center gap-4">
|
||||||
|
<div class="relative" x-data="{ open: false }">
|
||||||
|
<button @click="open = !open" class="bg-gray-100 px-4 py-2 rounded-lg hover:bg-gray-200">
|
||||||
|
Columnas ▼
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div x-show="open" @click.outside="open = false"
|
||||||
|
class="absolute bg-white shadow-lg rounded-lg p-4 mt-2 min-w-[200px] z-10">
|
||||||
|
@foreach($available_columns as $key => $label)
|
||||||
|
<label class="flex items-center gap-2 mb-2">
|
||||||
|
<input type="checkbox" wire:model.live="columns.{{ $key }}"
|
||||||
|
class="rounded border-gray-300">
|
||||||
|
{{ $label }}
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tabla -->
|
||||||
|
<div class="bg-white rounded-lg shadow overflow-x-auto">
|
||||||
|
<table class="min-w-full">
|
||||||
|
<thead class="bg-gray-50">
|
||||||
|
<tr>
|
||||||
|
@foreach($available_columns as $key => $label)
|
||||||
|
@if($columns[$key])
|
||||||
|
@if($key !== 'is_active')
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase cursor-pointer" >
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span wire:click="sortBy('{{ $key }}')">{{ $label }}</span>
|
||||||
|
<input type="text"
|
||||||
|
wire:model.live.debounce.300ms="filters.{{ $key }}"
|
||||||
|
class="mt-1 text-xs w-full border rounded px-2 py-1"
|
||||||
|
placeholder="Filtrar...">
|
||||||
|
</div>
|
||||||
|
@if($sortField === $key)
|
||||||
|
<span class="ml-2">
|
||||||
|
@if($sortDirection === 'asc')
|
||||||
|
↑
|
||||||
|
@else
|
||||||
|
↓
|
||||||
|
@endif
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
@else
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span>Estado</span>
|
||||||
|
<select wire:model.live="filters.status" class="mt-1 text-xs w-full border rounded px-2 py-1">
|
||||||
|
<option value="">Todos</option>
|
||||||
|
<option value="active">Activo</option>
|
||||||
|
<option value="inactive">Inactivo</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Acciones</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-200">
|
||||||
|
@foreach($users as $user)
|
||||||
|
<tr>
|
||||||
|
@if($columns['full_name'])
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<a href="{{ route('users.show', $user) }}" class="flex items-center hover:text-blue-600 hover:underline group">
|
||||||
|
<!-- Foto del usuario -->
|
||||||
|
@if($user->profile_photo_path)
|
||||||
|
<div class="mr-3 flex-shrink-0">
|
||||||
|
<img src="{{ asset($user->profile_photo_path) }}"
|
||||||
|
alt="{{ $user->full_name }}"
|
||||||
|
class="w-8 h-8 rounded-full object-cover transition-transform group-hover:scale-110">
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="w-8 h-8 rounded-full bg-gray-200 mr-3 flex items-center justify-center transition-colors group-hover:bg-blue-100">
|
||||||
|
<svg class="w-4 h-4 text-gray-500 group-hover:text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Nombre completo con efecto hover -->
|
||||||
|
<span class="group-hover:text-blue-600 transition-colors">
|
||||||
|
{{ $user->full_name }}
|
||||||
|
@if(!$user->is_active)
|
||||||
|
<span class="text-xs text-red-500 ml-2">(Inactivo)</span>
|
||||||
|
@endif
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@if($columns['username'])
|
||||||
|
{{ $user->username }}
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@if($columns['email'])
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
||||||
|
</svg>
|
||||||
|
{{ $user->email }}
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@if($columns['phone'])
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
|
||||||
|
</svg>
|
||||||
|
{{ $user->phone ?? 'N/A' }}
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@if($columns['access_start'])
|
||||||
|
{{ $user->access_start?->format('d/m/Y') }}
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@if($columns['created_at'])
|
||||||
|
{{ $user->created_at->format('d/m/Y H:i') }}
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@if($columns['is_active'])
|
||||||
|
{{ $user->is_active ? 'Activo' : 'Inactivo' }}
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<!-- Acciones -->
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<!-- Botón Editar -->
|
||||||
|
<a href="{{ route('users.edit', $user) }}"
|
||||||
|
class="text-blue-600 hover:text-blue-900"
|
||||||
|
title="Editar usuario">
|
||||||
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- Botón Eliminar -->
|
||||||
|
<button wire:click="confirmDelete({{ $user->id }})"
|
||||||
|
class="text-red-600 hover:text-red-900"
|
||||||
|
title="Eliminar usuario">
|
||||||
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Paginación -->
|
||||||
|
<div class="mt-4">
|
||||||
|
{{ $users->links() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,360 +1,378 @@
|
|||||||
<!-- resources/views/projects/create.blade.php -->
|
<!-- resources/views/projects/create.blade.php -->
|
||||||
|
|
||||||
<x-layouts.app :title="__('Create Project')">
|
<x-layouts.app :title="__('Create Project')">
|
||||||
<x-slot name="header">
|
<div class="max-w-4xl mx-auto px-0 py-4">
|
||||||
<h2 class="flex items-center gap-2 text-xl font-semibold leading-tight text-gray-800">
|
<header class="bg-white shadow">
|
||||||
<!-- Icono (ejemplo con Heroicons) -->
|
<div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<h2 class="flex items-center text-xl font-semibold leading-tight text-gray-800">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
</svg>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
{{ __('Nuevo Proyecto') }}
|
||||||
|
|
||||||
|
@error('error')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('projects.store') }}" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
|
||||||
{{ __('Nuevo Proyecto') }}
|
<!-- Separador -->
|
||||||
</h2>
|
<div class="relative">
|
||||||
</x-slot>
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
<header class="bg-white shadow">
|
</div>
|
||||||
<div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8">
|
<div class="relative flex justify-center">
|
||||||
<h2 class="flex items-center text-xl font-semibold leading-tight text-gray-800">
|
<span class="px-4 bg-white text-sm text-gray-500">Datos Generales</span>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
|
|
||||||
</svg>
|
|
||||||
{{ __('Nuevo Proyecto') }}
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="py-6">
|
|
||||||
<div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8">
|
|
||||||
<div class="overflow-hidden bg-white shadow-sm sm:rounded-lg">
|
|
||||||
<div class="p-6 bg-white border-b border-gray-200">
|
|
||||||
<form method="POST" action="{{ route('projects.store') }}" enctype="multipart/form-data">
|
|
||||||
@csrf
|
|
||||||
|
|
||||||
<table class="w-full mb-8">
|
|
||||||
<tbody>
|
|
||||||
<!-- Nombre -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label for="name" :value="__('Nombre del Proyecto')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<x-input id="name"
|
|
||||||
class="block w-[150px] mt-1 border-0 border-b border-gray-300 focus:ring-0 focus:border-blue-500"
|
|
||||||
type="text" name="name"
|
|
||||||
:value="old('name')"
|
|
||||||
required />
|
|
||||||
@error('name')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Descripción -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label for="description" :value="__('Descripción')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<x-textarea id="description" class="block w-full mt-1" name="description" rows="4" required>
|
|
||||||
{{ old('description') }}
|
|
||||||
</x-textarea>
|
|
||||||
@error('description')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Editor Enriquecido -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label for="description" :value="__('Descripción Detallada')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div id="editor-container">
|
|
||||||
<!-- Barra de herramientas -->
|
|
||||||
<div id="toolbar">
|
|
||||||
<button class="ql-bold"></button>
|
|
||||||
<button class="ql-italic"></button>
|
|
||||||
<button class="ql-underline"></button>
|
|
||||||
<button class="ql-strike"></button>
|
|
||||||
<button class="ql-blockquote"></button>
|
|
||||||
<button class="ql-code-block"></button>
|
|
||||||
<button class="ql-link"></button>
|
|
||||||
<button class="ql-image"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Editor -->
|
|
||||||
<input type="hidden" name="description">
|
|
||||||
<div id="rich-editor" class="h-48">{!! old('description') !!}</div>
|
|
||||||
</div>
|
|
||||||
@error('description')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Estado -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label for="status" :value="__('Estado del Proyecto')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<x-select id="status" name="status" class="block w-full mt-1">
|
|
||||||
<option :value="active" {{ old('status') == 'active' ? 'selected' : '' }}>Activo</option>
|
|
||||||
<option :value="inactive" {{ old('status') == 'inactive' ? 'selected' : '' }}>Inactivo</option>
|
|
||||||
</x-select>
|
|
||||||
@error('status')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Imagen de Referencia -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label for="reference_image" :value="__('Imagen de Referencia')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div class="relative mt-1">
|
|
||||||
<input type="file" id="project_image" name="project_image"
|
|
||||||
class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4
|
|
||||||
file:rounded-md file:border-0
|
|
||||||
file:text-sm file:font-semibold
|
|
||||||
file:bg-blue-50 file:text-blue-700
|
|
||||||
hover:file:bg-blue-100"
|
|
||||||
accept="image/*"
|
|
||||||
onchange="previewImage(event)">
|
|
||||||
<div class="mt-2" id="image-preview-container" style="display:none;">
|
|
||||||
<img id="image-preview" class="object-cover h-48 w-full rounded-lg">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@error('project_image')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Dirección -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label :value="__('Ubicación')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
|
||||||
<div>
|
|
||||||
<x-input id="address" class="block w-full mt-1"
|
|
||||||
type="text" name="address"
|
|
||||||
:value="old('address')"
|
|
||||||
placeholder="Dirección" />
|
|
||||||
@error('address')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-input id="postal_code" class="block w-full mt-1"
|
|
||||||
type="text" name="postal_code"
|
|
||||||
:value="old('postal_code')"
|
|
||||||
placeholder="Código Postal" />
|
|
||||||
@error('postal_code')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-input id="province" class="block w-full mt-1"
|
|
||||||
type="text" name="province"
|
|
||||||
:value="old('province')"
|
|
||||||
placeholder="Provincia" />
|
|
||||||
@error('province')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-select id="country" name="country" class="block w-full mt-1">
|
|
||||||
<option :value="">Seleccione País</option>
|
|
||||||
@foreach(config('countries') as $code => $name)
|
|
||||||
<option :value="{{ $code }}" {{ old('country') == $code ? 'selected' : '' }}>
|
|
||||||
{{ $name }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
</x-select>
|
|
||||||
@error('country')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Mapa para Coordenadas -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label :value="__('Seleccione Ubicación en el Mapa')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div id="map" class="h-64 rounded-lg border-2 border-gray-200"></div>
|
|
||||||
<div class="grid grid-cols-2 gap-4 mt-2">
|
|
||||||
<div>
|
|
||||||
<x-label for="latitude" :value="__('Latitud')" />
|
|
||||||
<x-input id="latitude" name="latitude"
|
|
||||||
type="number" step="any"
|
|
||||||
:value="old('latitude')" required />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<x-label for="longitude" :value="__('Longitud')" />
|
|
||||||
<x-input id="longitude" name="longitude"
|
|
||||||
type="number" step="any"
|
|
||||||
:value="old('longitude')" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@error('latitude')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
@error('longitude')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Icono y Categorías -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label :value="__('Identificación Visual')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div class="grid grid-cols-2 gap-4">
|
|
||||||
<div>
|
|
||||||
<x-label for="icon" :value="__('Icono del Proyecto')" />
|
|
||||||
<div class="relative mt-1">
|
|
||||||
<select id="icon" name="icon"
|
|
||||||
class="w-full rounded-md shadow-sm border-gray-300 focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
|
|
||||||
<option :value="">Seleccionar Icono</option>
|
|
||||||
@foreach(config('project.icons') as $icon)
|
|
||||||
<option :value="{{ $icon }}"
|
|
||||||
{{ old('icon') == $icon ? 'selected' : '' }}>
|
|
||||||
<i class="fas fa-{{ $icon }} mr-2"></i>
|
|
||||||
{{ Str::title($icon) }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-label for="categories" :value="__('Categorías')" />
|
|
||||||
<x-multiselect
|
|
||||||
name="categories[]"
|
|
||||||
:options="$categories"
|
|
||||||
:selected="old('categories', [])"
|
|
||||||
placeholder="Seleccione categorías"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Fechas Importantes -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label for="start_date" :value="__('Fechas')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div class="flex items-center gap-4 mt-2">
|
|
||||||
<span class="text-gray-700">de</span>
|
|
||||||
<x-input id="start_date" type="date" name="start_date" :value="old('start_date')" />
|
|
||||||
<span class="text-gray-700">a</span>
|
|
||||||
<x-input id="deadline" type="date" name="deadline" :value="old('deadline')" min="{{ now()->format('Y-m-d') }}" />
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Archivos Adjuntos -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label :value="__('Documentos Iniciales')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div x-data="{ files: [] }" class="mt-1">
|
|
||||||
<div class="flex items-center justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
|
||||||
<div class="text-center">
|
|
||||||
<input type="file"
|
|
||||||
name="documents[]"
|
|
||||||
multiple
|
|
||||||
class="absolute opacity-0"
|
|
||||||
x-ref="fileInput"
|
|
||||||
@change="files = Array.from($event.target.files)">
|
|
||||||
|
|
||||||
<template x-if="files.length === 0">
|
|
||||||
<div>
|
|
||||||
<x-icons.upload class="mx-auto h-12 w-12 text-gray-400" />
|
|
||||||
<p class="mt-1 text-sm text-gray-600">
|
|
||||||
Arrastra archivos o haz clic para subir
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template x-if="files.length > 0">
|
|
||||||
<div class="space-y-2">
|
|
||||||
<template x-for="(file, index) in files" :key="index">
|
|
||||||
<div class="flex items-center text-sm text-gray-600">
|
|
||||||
<x-icons icon="document" class="w-5 h-5 mr-2" />
|
|
||||||
<span x-text="file.name"></span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<!-- Miembros del Equipo -->
|
|
||||||
<tr>
|
|
||||||
<td class="w-1/4 py-3 pr-4 align-top">
|
|
||||||
<x-label :value="__('Miembros del Equipo')" />
|
|
||||||
</td>
|
|
||||||
<td class="py-3">
|
|
||||||
<div class="grid grid-cols-1 mt-2 gap-y-2 gap-x-4 sm:grid-cols-2">
|
|
||||||
@foreach($users as $user)
|
|
||||||
<label class="flex items-center space-x-2">
|
|
||||||
<input type="checkbox"
|
|
||||||
name="team[]"
|
|
||||||
value="{{ $user->id }}"
|
|
||||||
{{ in_array($user->id, old('team', [])) ? 'checked' : '' }}
|
|
||||||
class="rounded border-gray-300 text-blue-600 shadow-sm focus:ring-blue-500">
|
|
||||||
<span class="text-sm text-gray-700">{{ $user->name }}</span>
|
|
||||||
</label>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
@error('team')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- Botones de Acción -->
|
|
||||||
<div class="flex justify-end mt-8 space-x-4">
|
|
||||||
<a href="{{ route('projects.index') }}"
|
|
||||||
class="px-4 py-2 text-gray-600 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50">
|
|
||||||
{{ __('Cancelar') }}
|
|
||||||
</a>
|
|
||||||
<x-button type="submit" class="bg-blue-600 hover:bg-blue-700">
|
|
||||||
<x-icons icon="save" class="w-5 h-5 mr-2" />
|
|
||||||
{{ __('Crear Proyecto') }}
|
|
||||||
</x-button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@push('styles')
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full mb-8">
|
||||||
|
<tbody>
|
||||||
|
<!-- Nombre -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label for="name" :value="__('Nombre del Proyecto')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<input type="text" name="name"
|
||||||
|
value="{{ old('name', $project->name ?? '') }}"
|
||||||
|
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none"
|
||||||
|
autofocus
|
||||||
|
required>
|
||||||
|
|
||||||
|
@error('name')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Descripción -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label for="description" :value="__('Descripción')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<x-textarea id="description" class="block w-full mt-1" name="description" rows="4" required>
|
||||||
|
{{ old('description') }}
|
||||||
|
</x-textarea>
|
||||||
|
@error('description')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Estado -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label for="status" :value="__('Estado del Proyecto')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<x-select id="status" name="status" class="block w-full mt-1">
|
||||||
|
<option :value="active" {{ old('status') == 'active' ? 'selected' : '' }}>Activo</option>
|
||||||
|
<option :value="inactive" {{ old('status') == 'inactive' ? 'selected' : '' }}>Inactivo</option>
|
||||||
|
</x-select>
|
||||||
|
@error('status')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Fechas Importantes -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label for="start_date" :value="__('Fechas')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div class="flex gap-4">
|
||||||
|
<span class="text-gray-700">de</span>
|
||||||
|
<input type="date"
|
||||||
|
id="start_date"
|
||||||
|
name="start_date"
|
||||||
|
value="{{ old('start_date') }}"
|
||||||
|
class="w-[150px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
<span class="text-gray-700">a</span>
|
||||||
|
<input type="date"
|
||||||
|
id="deadline"
|
||||||
|
name="deadline"
|
||||||
|
value="{{ old('end_date') }}"
|
||||||
|
class="w-[150px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
|
</div>
|
||||||
|
<div class="relative flex justify-center">
|
||||||
|
<span class="px-4 bg-white text-sm text-gray-500">Ubicación </span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full mb-8">
|
||||||
|
<tbody>
|
||||||
|
<!-- Dirección -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label :value="__('Dirección')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div class="grid grid-cols-1 gap-4 sm:grid-cols-1">
|
||||||
|
<div>
|
||||||
|
<textarea id="address"
|
||||||
|
name="address"
|
||||||
|
rows="3"
|
||||||
|
class="w-full border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">{{ old('address') }}
|
||||||
|
|
||||||
|
</textarea>
|
||||||
|
|
||||||
|
@error('address')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="text"
|
||||||
|
id="postal_code"
|
||||||
|
name="postal_code"
|
||||||
|
value="{{ old('postal_code') }}"
|
||||||
|
placeholder="Código Postal"
|
||||||
|
class="w-[120px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
@error('postal_code')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="text"
|
||||||
|
id="province"
|
||||||
|
name="province"
|
||||||
|
value="{{ old('province') }}"
|
||||||
|
placeholder="Provincia"
|
||||||
|
class="w-[300px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
@error('province')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<livewire:country-select :initialCountry="old('country')" />
|
||||||
|
@error('country')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Mapa para Coordenadas -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label :value="__('Seleccione Ubicación')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div id="map" class="h-64 border-2 border-gray-200"></div>
|
||||||
|
<div class="grid grid-cols-2 gap-4 mt-2">
|
||||||
|
<div>
|
||||||
|
<x-label for="latitude" :value="__('Latitud')" />
|
||||||
|
<input type="number"
|
||||||
|
id="latitude"
|
||||||
|
name="latitude"
|
||||||
|
value="{{ old('latitude') }}"
|
||||||
|
step="any"
|
||||||
|
class="border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<x-label for="longitude" :value="__('Longitud')" />
|
||||||
|
<input type="number"
|
||||||
|
id="latitude"
|
||||||
|
name="latitude"
|
||||||
|
value="{{ old('latitude') }}"
|
||||||
|
step="any"
|
||||||
|
class="border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@error('latitude')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
@error('longitude')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
|
</div>
|
||||||
|
<div class="relative flex justify-center">
|
||||||
|
<span class="px-4 bg-white text-sm text-gray-500">Otros datos</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full mb-8">
|
||||||
|
<tbody>
|
||||||
|
<!-- Imagen de Referencia -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label for="reference_image" :value="__('Imagen de Referencia')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div class="relative mt-1">
|
||||||
|
<input type="file" id="project_image" name="project_image"
|
||||||
|
class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4
|
||||||
|
file:rounded-md file:border-0
|
||||||
|
file:text-sm file:font-semibold
|
||||||
|
file:bg-blue-50 file:text-blue-700
|
||||||
|
hover:file:bg-blue-100"
|
||||||
|
accept="image/*"
|
||||||
|
onchange="previewImage(event)">
|
||||||
|
<div class="mt-2" id="image-preview-container" style="display:none;">
|
||||||
|
<img id="image-preview" class="object-cover h-48 w-full rounded-lg">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@error('project_image')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Icono y Categorías -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label :value="__('Identificación Visual')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div class="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<x-label for="icon" :value="__('Icono del Proyecto')" />
|
||||||
|
<div class="relative mt-1">
|
||||||
|
<select id="icon" name="icon"
|
||||||
|
class="w-full rounded-md shadow-sm border-gray-300 focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
|
||||||
|
<option :value="">Seleccionar Icono</option>
|
||||||
|
@foreach(config('project.icons') as $icon)
|
||||||
|
<option :value="{{ $icon }}"
|
||||||
|
{{ old('icon') == $icon ? 'selected' : '' }}>
|
||||||
|
<i class="fas fa-{{ $icon }} mr-2"></i>
|
||||||
|
{{ Str::title($icon) }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<x-label for="categories" :value="__('Categorías')" />
|
||||||
|
<x-multiselect
|
||||||
|
name="categories[]"
|
||||||
|
:options="$categories"
|
||||||
|
:selected="old('categories', [])"
|
||||||
|
placeholder="Seleccione categorías"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Archivos Adjuntos -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label :value="__('Documentos Iniciales')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div x-data="{ files: [] }" class="mt-1">
|
||||||
|
<div class="flex items-center justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
||||||
|
<div class="text-center">
|
||||||
|
<input type="file"
|
||||||
|
name="documents[]"
|
||||||
|
multiple
|
||||||
|
class="absolute opacity-0"
|
||||||
|
x-ref="fileInput"
|
||||||
|
@change="files = Array.from($event.target.files)">
|
||||||
|
|
||||||
|
<template x-if="files.length === 0">
|
||||||
|
<div>
|
||||||
|
<x-icons.upload class="mx-auto h-12 w-12 text-gray-400" />
|
||||||
|
<p class="mt-1 text-sm text-gray-600">
|
||||||
|
Arrastra archivos o haz clic para subir
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template x-if="files.length > 0">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<template x-for="(file, index) in files" :key="index">
|
||||||
|
<div class="flex items-center text-sm text-gray-600">
|
||||||
|
<x-icons icon="document" class="w-5 h-5 mr-2" />
|
||||||
|
<span x-text="file.name"></span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Miembros del Equipo -->
|
||||||
|
<tr>
|
||||||
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
|
<x-label :value="__('Miembros del Equipo')" />
|
||||||
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<div class="grid grid-cols-1 mt-2 gap-y-2 gap-x-4 sm:grid-cols-2">
|
||||||
|
@foreach($users as $user)
|
||||||
|
<label class="flex items-center space-x-2">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="team[]"
|
||||||
|
value="{{ $user->id }}"
|
||||||
|
{{ in_array($user->id, old('team', [])) ? 'checked' : '' }}
|
||||||
|
class="rounded border-gray-300 text-blue-600 shadow-sm focus:ring-blue-500">
|
||||||
|
<span class="text-sm text-gray-700">{{ $user->first_name}} {{ $user->last_name}}</span>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@error('team')
|
||||||
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botones de Acción -->
|
||||||
|
<div class="flex justify-end mt-8 space-x-4">
|
||||||
|
<a href="{{ route('projects.index') }}"
|
||||||
|
class="px-4 py-2 text-gray-600 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50">
|
||||||
|
{{ __('Cancelar') }}
|
||||||
|
</a>
|
||||||
|
<x-button type="submit" class="bg-blue-600 hover:bg-blue-700">
|
||||||
|
<x-icons icon="save" class="w-5 h-5 mr-2" />
|
||||||
|
{{ __('Crear Proyecto') }}
|
||||||
|
</x-button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css" rel="stylesheet" />
|
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css" rel="stylesheet" />
|
||||||
|
|
||||||
@@ -363,11 +381,7 @@
|
|||||||
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
||||||
crossorigin=""/>
|
crossorigin=""/>
|
||||||
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@push('scripts')
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"></script>
|
||||||
<!-- Leaflet JS -->
|
<!-- Leaflet JS -->
|
||||||
@@ -469,5 +483,4 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@endpush
|
|
||||||
</x-layouts.app>
|
</x-layouts.app>
|
||||||
@@ -1,386 +0,0 @@
|
|||||||
<!-- resources/views/projects/create.blade.php -->
|
|
||||||
<x-layouts.app :title="__('Create Project')">
|
|
||||||
<x-slot name="header">
|
|
||||||
<h2 class="text-xl font-semibold leading-tight text-gray-800">
|
|
||||||
Nuevo Proyecto
|
|
||||||
</h2>
|
|
||||||
</x-slot>
|
|
||||||
|
|
||||||
<div class="py-6">
|
|
||||||
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
|
|
||||||
<div class="overflow-hidden bg-white shadow-sm sm:rounded-lg">
|
|
||||||
<div class="p-6 bg-white border-b border-gray-200">
|
|
||||||
<form method="POST" action="{{ route('projects.store') }}" enctype="multipart/form-data">
|
|
||||||
@csrf
|
|
||||||
<!-- Sección de Información Básica -->
|
|
||||||
<div class="grid gap-6 mb-8 md:grid-cols-2">
|
|
||||||
<!-- Columna Izquierda -->
|
|
||||||
<div>
|
|
||||||
<!-- Nombre -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label for="name" value="__('Nombre del Proyecto')" />
|
|
||||||
<x-input id="name" class="block w-full mt-1"
|
|
||||||
type="text" name="name" value="old('name')" required />
|
|
||||||
@error('name')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Descripción -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label for="description" value="__('Descripción')" />
|
|
||||||
<x-textarea id="description" class="block w-full mt-1"
|
|
||||||
name="description" rows="4" required>
|
|
||||||
{{ old('description') }}
|
|
||||||
</x-textarea>
|
|
||||||
@error('description')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Editor Enriquecido -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label for="description" value="__('Descripción Detallada')" />
|
|
||||||
<div id="editor-container">
|
|
||||||
<!-- Barra de herramientas -->
|
|
||||||
<div id="toolbar">
|
|
||||||
<button class="ql-bold"></button>
|
|
||||||
<button class="ql-italic"></button>
|
|
||||||
<button class="ql-underline"></button>
|
|
||||||
<button class="ql-strike"></button>
|
|
||||||
<button class="ql-blockquote"></button>
|
|
||||||
<button class="ql-code-block"></button>
|
|
||||||
<button class="ql-link"></button>
|
|
||||||
<button class="ql-image"></button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Editor -->
|
|
||||||
<div id="rich-editor">{!! old('description') !!}</div>
|
|
||||||
</div>
|
|
||||||
@error('description')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Estado -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label for="status" value="__('Estado del Proyecto')" />
|
|
||||||
<x-select id="status" name="status" class="block w-full mt-1">
|
|
||||||
<option value="active" {{ old('status') == 'active' ? 'selected' : '' }}>Activo</option>
|
|
||||||
<option value="inactive" {{ old('status') == 'inactive' ? 'selected' : '' }}>Inactivo</option>
|
|
||||||
</x-select>
|
|
||||||
@error('status')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Imagen de Referencia -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label for="project_image" value="__('Imagen de Referencia')" />
|
|
||||||
<div class="relative mt-1">
|
|
||||||
<input type="file" id="project_image" name="project_image"
|
|
||||||
class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4
|
|
||||||
file:rounded-md file:border-0
|
|
||||||
file:text-sm file:font-semibold
|
|
||||||
file:bg-blue-50 file:text-blue-700
|
|
||||||
hover:file:bg-blue-100"
|
|
||||||
accept="image/*"
|
|
||||||
onchange="previewImage(event)">
|
|
||||||
<div class="mt-2" id="image-preview-container" style="display:none;">
|
|
||||||
<img id="image-preview" class="object-cover h-48 w-full rounded-lg">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@error('project_image')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Columna Derecha -->
|
|
||||||
<div>
|
|
||||||
<!-- Dirección -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label value="__('Ubicación')" />
|
|
||||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
|
||||||
<div>
|
|
||||||
<x-input id="address" class="block w-full mt-1"
|
|
||||||
type="text" name="address"
|
|
||||||
value="old('address')"
|
|
||||||
placeholder="Dirección" />
|
|
||||||
@error('address')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-input id="postal_code" class="block w-full mt-1"
|
|
||||||
type="text" name="postal_code"
|
|
||||||
value="old('postal_code')"
|
|
||||||
placeholder="Código Postal" />
|
|
||||||
@error('postal_code')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-input id="province" class="block w-full mt-1"
|
|
||||||
type="text" name="province"
|
|
||||||
value="old('province')"
|
|
||||||
placeholder="Provincia" />
|
|
||||||
@error('province')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-select id="country" name="country" class="block w-full mt-1">
|
|
||||||
<option value="">Seleccione País</option>
|
|
||||||
@foreach(config('countries') as $code => $name)
|
|
||||||
<option value="{{ $code }}" {{ old('country') == $code ? 'selected' : '' }}>
|
|
||||||
{{ $name }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
</x-select>
|
|
||||||
@error('country')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mapa para Coordenadas -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label value="__('Seleccione Ubicación en el Mapa')" />
|
|
||||||
<div id="map" class="h-64 rounded-lg border-2 border-gray-200"></div>
|
|
||||||
<div class="grid grid-cols-2 gap-4 mt-2">
|
|
||||||
<div>
|
|
||||||
<x-label for="latitude" value="__('Latitud')" />
|
|
||||||
<x-input id="latitude" name="latitude"
|
|
||||||
type="number" step="any"
|
|
||||||
value="old('latitude')" required />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<x-label for="longitude" value="__('Longitud')" />
|
|
||||||
<x-input id="longitude" name="longitude"
|
|
||||||
type="number" step="any"
|
|
||||||
value="old('longitude')" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@error('latitude')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
@error('longitude')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Sección Principal en 2 Columnas -->
|
|
||||||
<div class="grid gap-6 mb-8 md:grid-cols-2">
|
|
||||||
<!-- Columna Izquierda -->
|
|
||||||
<div>
|
|
||||||
<!-- Icono y Categorías -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label value="__('Identificación Visual')" />
|
|
||||||
<div class="grid grid-cols-2 gap-4">
|
|
||||||
<div>
|
|
||||||
<x-label for="icon" value="__('Icono del Proyecto')" />
|
|
||||||
<div class="relative mt-1">
|
|
||||||
<select id="icon" name="icon"
|
|
||||||
class="w-full rounded-md shadow-sm border-gray-300 focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
|
|
||||||
<option value="">Seleccionar Icono</option>
|
|
||||||
@foreach(config('project.icons') as $icon)
|
|
||||||
<option value="{{ $icon }}"
|
|
||||||
{{ old('icon') == $icon ? 'selected' : '' }}>
|
|
||||||
<i class="fas fa-{{ $icon }} mr-2"></i>
|
|
||||||
{{ Str::title($icon) }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<x-label for="categories" value="__('Categorías')" />
|
|
||||||
<x-multiselect
|
|
||||||
name="categories[]"
|
|
||||||
:options="$categories"
|
|
||||||
:selected="old('categories', [])"
|
|
||||||
placeholder="Seleccione categorías"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Fechas Importantes -->
|
|
||||||
<div class="grid grid-cols-2 gap-4 mb-6">
|
|
||||||
<div>
|
|
||||||
<x-label for="start_date" value="__('Fecha de Inicio')" />
|
|
||||||
<x-input id="start_date" type="date"
|
|
||||||
name="start_date" value="old('start_date')" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<x-label for="deadline" value="__('Fecha Límite')" />
|
|
||||||
<x-input id="deadline" type="date"
|
|
||||||
name="deadline" value="old('deadline')"
|
|
||||||
min="{{ now()->format('Y-m-d') }}" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Columna Derecha -->
|
|
||||||
<div>
|
|
||||||
<!-- Archivos Adjuntos -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<x-label value="__('Documentos Iniciales')" />
|
|
||||||
<div x-data="{ files: [] }" class="mt-1">
|
|
||||||
<div class="flex items-center justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
|
||||||
<div class="text-center">
|
|
||||||
<input type="file"
|
|
||||||
name="documents[]"
|
|
||||||
multiple
|
|
||||||
class="absolute opacity-0"
|
|
||||||
x-ref="fileInput"
|
|
||||||
@change="files = Array.from($event.target.files)">
|
|
||||||
|
|
||||||
<template x-if="files.length === 0">
|
|
||||||
<div>
|
|
||||||
<x-icons.upload class="mx-auto h-12 w-12 text-gray-400" />
|
|
||||||
<p class="mt-1 text-sm text-gray-600">
|
|
||||||
Arrastra archivos o haz clic para subir
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template x-if="files.length > 0">
|
|
||||||
<div class="space-y-2">
|
|
||||||
<template x-for="(file, index) in files" :key="index">
|
|
||||||
<div class="flex items-center text-sm text-gray-600">
|
|
||||||
<x-icons icon="document" class="w-5 h-5 mr-2" />
|
|
||||||
<span x-text="file.name"></span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mapa y Ubicación (Implementación previa) -->
|
|
||||||
<!-- ... (Mantener sección de mapa y ubicación anterior) ... -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Resto del formulario -->
|
|
||||||
<!-- ... (Mantener secciones anteriores de equipo, estado, etc) ... -->
|
|
||||||
|
|
||||||
<!-- Miembros del Equipo -->
|
|
||||||
<div class="mb-6">
|
|
||||||
Miembros del Equipo
|
|
||||||
<x-label value="__('Miembros del Equipo')" />
|
|
||||||
<div class="grid grid-cols-1 mt-2 gap-y-2 gap-x-4 sm:grid-cols-2">
|
|
||||||
@foreach($users as $user)
|
|
||||||
<label class="flex items-center space-x-2">
|
|
||||||
<input type="checkbox"
|
|
||||||
name="team[]"
|
|
||||||
value="{{ $user->id }}"
|
|
||||||
{{ in_array($user->id, old('team', [])) ? 'checked' : '' }}
|
|
||||||
class="rounded border-gray-300 text-blue-600 shadow-sm focus:ring-blue-500">
|
|
||||||
<span class="text-sm text-gray-700">{{ $user->name }}</span>
|
|
||||||
</label>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
@error('team')
|
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Botones de Acción -->
|
|
||||||
<div class="flex justify-end mt-8 space-x-4">
|
|
||||||
<a href="{{ route('projects.index') }}"
|
|
||||||
class="px-4 py-2 text-gray-600 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50">
|
|
||||||
{{ __('Cancelar') }}
|
|
||||||
</a>
|
|
||||||
<x-button type="submit" class="bg-blue-600 hover:bg-blue-700">
|
|
||||||
<x-icons icon="save" class="w-5 h-5 mr-2" />
|
|
||||||
{{ __('Crear Proyecto') }}
|
|
||||||
</x-button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@push('styles')
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css" rel="stylesheet" />
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
@push('scripts')
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"></script>
|
|
||||||
<script>
|
|
||||||
// Editor Quill
|
|
||||||
onst toolbarOptions = [
|
|
||||||
['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
|
||||||
['blockquote', 'code-block'],
|
|
||||||
['link', 'image', 'video', 'formula'],
|
|
||||||
|
|
||||||
[{ 'header': 1 }, { 'header': 2 }], // custom button values
|
|
||||||
[{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
|
|
||||||
[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
|
|
||||||
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
|
|
||||||
[{ 'direction': 'rtl' }], // text direction
|
|
||||||
|
|
||||||
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
|
|
||||||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
|
|
||||||
|
|
||||||
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
|
|
||||||
[{ 'font': [] }],
|
|
||||||
[{ 'align': [] }],
|
|
||||||
|
|
||||||
['clean'] // remove formatting button
|
|
||||||
];
|
|
||||||
|
|
||||||
const quill = new Quill('#rich-editor', {
|
|
||||||
theme: 'snow',
|
|
||||||
modules: {
|
|
||||||
toolbar: toolbarOptions,
|
|
||||||
placeholder: 'Description...',
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Tagify para categorías
|
|
||||||
new Tagify(document.querySelector('[name="categories[]"]'), {
|
|
||||||
enforceWhitelist: true,
|
|
||||||
whitelist: @json($categories->pluck('name')),
|
|
||||||
dropdown: {
|
|
||||||
enabled: 1,
|
|
||||||
maxItems: 5
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
function previewImage(event) {
|
|
||||||
const reader = new FileReader();
|
|
||||||
const preview = document.getElementById('image-preview');
|
|
||||||
|
|
||||||
reader.onload = function() {
|
|
||||||
preview.innerHTML = `
|
|
||||||
<img src="${reader.result}"
|
|
||||||
class="object-cover w-full h-48 rounded-lg shadow-sm"
|
|
||||||
alt="Vista previa de la imagen">
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(event.target.files[0]) {
|
|
||||||
reader.readAsDataURL(event.target.files[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@endpush
|
|
||||||
</x-layouts.app>
|
|
||||||
29
resources/views/projects/show.blade.php
Normal file
29
resources/views/projects/show.blade.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<x-layouts.app :title="__('Show Project')">
|
||||||
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-6">
|
||||||
|
<!-- Barra de herramientas con breadcrumbs -->
|
||||||
|
<div class="mb-6">
|
||||||
|
<nav class="flex" aria-label="Breadcrumb">
|
||||||
|
<ol class="flex items-center space-x-2">
|
||||||
|
<li>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<a href="{{ route('projects.index') }}" class="text-gray-400 hover:text-gray-500">
|
||||||
|
<x-icons icon="home" class="h-5 w-5" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Barra de herramientas principal -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Componente principal Livewire -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Modales -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</x-layouts.app>
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
@extends('layouts.app')
|
|
||||||
|
|
||||||
@section('content')
|
|
||||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-6">
|
|
||||||
<!-- Barra de herramientas con breadcrumbs -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<nav class="flex" aria-label="Breadcrumb">
|
|
||||||
<ol class="flex items-center space-x-2">
|
|
||||||
<li>
|
|
||||||
<div class="flex items-center">
|
|
||||||
<a href="{{ route('projects.index') }}" class="text-gray-400 hover:text-gray-500">
|
|
||||||
<x-icons.home class="h-5 w-5" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
@foreach($breadcrumbs as $crumb)
|
|
||||||
<li>
|
|
||||||
<div class="flex items-center">
|
|
||||||
<x-icons.chevron-right class="h-5 w-5 text-gray-400" />
|
|
||||||
@if(!$loop->last)
|
|
||||||
<a href="{{ $crumb['url'] }}" class="ml-2 text-sm font-medium text-gray-500 hover:text-gray-700">
|
|
||||||
{{ $crumb['name'] }}
|
|
||||||
</a>
|
|
||||||
@else
|
|
||||||
<span class="ml-2 text-sm font-medium text-gray-700">{{ $crumb['name'] }}</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
@endforeach
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Barra de herramientas principal -->
|
|
||||||
<x-toolbar :project="$project" :current-folder="$currentFolder" />
|
|
||||||
|
|
||||||
<!-- Componente principal Livewire -->
|
|
||||||
<livewire:project-show
|
|
||||||
:project="$project"
|
|
||||||
:current-folder="$currentFolder ?? null"
|
|
||||||
wire:key="project-show-{{ $project->id }}-{{ $currentFolder->id ?? 'root' }}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- Modales -->
|
|
||||||
@livewire('folder.create-modal', ['project' => $project, 'parentFolder' => $currentFolder ?? null])
|
|
||||||
@livewire('document.upload-modal', ['project' => $project, 'currentFolder' => $currentFolder ?? null])
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
||||||
342
resources/views/users/create.blade.php
Normal file
342
resources/views/users/create.blade.php
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
<x-layouts.app title="{{ isset($user) ? __('Edit User') : __('Create User') }}">
|
||||||
|
<div class="max-w-4xl mx-auto px-0 py-4">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="flex items-center gap-4 mb-4">
|
||||||
|
<svg class="w-10 h-10 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
||||||
|
</svg>
|
||||||
|
<h1 class="text-3xl font-bold text-gray-800">
|
||||||
|
{{ isset($user) ? 'Editar Usuario' : 'Nuevo Usuario' }}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<p class="text-gray-600 text-sm">
|
||||||
|
@isset($user)
|
||||||
|
Modifique los campos necesarios para actualizar la información del usuario.
|
||||||
|
@else
|
||||||
|
Complete todos los campos obligatorios para registrar un nuevo usuario en el sistema.
|
||||||
|
@endisset
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@if(session('error'))
|
||||||
|
<div id="error-message" class="mb-4 p-4 bg-red-100 border border-red-400 text-red-700 rounded">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($errors->any())
|
||||||
|
<div class="mb-4 p-4 bg-red-100 border border-red-400 text-red-700 rounded">
|
||||||
|
<ul>
|
||||||
|
@foreach($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form method="POST" action="{{ isset($user) ? route('users.update', $user) : route('users.store') }}">
|
||||||
|
@csrf
|
||||||
|
@isset($user)
|
||||||
|
@method('PUT')
|
||||||
|
@endisset
|
||||||
|
|
||||||
|
<!-- Separador -->
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
|
</div>
|
||||||
|
<div class="relative flex justify-center">
|
||||||
|
<span class="px-4 bg-white text-sm text-gray-500">Datos Personales</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Datos Personales -->
|
||||||
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full">
|
||||||
|
<tbody class="space-y-4">
|
||||||
|
<!-- Título de cortesía -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4 w-1/3">
|
||||||
|
<label class="block text-sm font-medium text-gray-700">
|
||||||
|
Título de cortesía
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<select name="title" class="w-[150px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
<option value="">Seleccionar...</option>
|
||||||
|
<option value="Sr.">Sr.</option>
|
||||||
|
<option value="Sra.">Sra.</option>
|
||||||
|
<option value="Dr.">Dr.</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Nombre -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Nombre
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<input type="text" name="first_name" required
|
||||||
|
value="{{ old('first_name', $user->first_name ?? '') }}"
|
||||||
|
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none"
|
||||||
|
autofocus>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Apellidos -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Apellidos
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<input type="text" name="last_name" required
|
||||||
|
value="{{ old('last_name', $user->last_name ?? '') }}"
|
||||||
|
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Nombre de Login -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Nombre de Login
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<input type="text" name="username" required
|
||||||
|
value="{{ old('username', $user->username ?? '') }}"
|
||||||
|
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Separador -->
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
|
</div>
|
||||||
|
<div class="relative flex justify-center">
|
||||||
|
<span class="px-4 bg-white text-sm text-gray-500">Configuración de acceso</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Configuración de Acceso -->
|
||||||
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full">
|
||||||
|
<tbody>
|
||||||
|
<!-- Intervalo de fechas -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4 w-1/3">
|
||||||
|
<label class="block text-sm font-medium text-gray-700">
|
||||||
|
Validez de acceso
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="flex gap-4">
|
||||||
|
de
|
||||||
|
<input type="date" name="start_date"
|
||||||
|
value="{{ old('start_date', isset($user->access_start) ? $user->access_start->format('Y-m-d') : '') }}"
|
||||||
|
class="w-[150px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
a
|
||||||
|
<input type="date" name="end_date"
|
||||||
|
value="{{ old('end_date', isset($user->access_end) ? $user->access_end->format('Y-m-d') : '') }}"
|
||||||
|
class="w-[150px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Contraseña -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Contraseña
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<input type="text" name="password" id="password"
|
||||||
|
{{ !isset($user) ? 'required' : '' }}
|
||||||
|
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
<button type="button" onclick="generatePassword()"
|
||||||
|
class="px-2 py-1 bg-blue-100 text-blue-700 rounded-md hover:bg-blue-200 flex items-center gap-2">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||||
|
<path fill-rule="evenodd" d="M18 8a6 6 0 01-7.743 5.743L10 14l-1 1-1 1H6v2H2v-4l4.257-4.257A6 6 0 1118 8zm-6-4a1 1 0 100 2 2 2 0 012 2 1 1 0 102 0 4 4 0 00-4-4z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Separador -->
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
|
</div>
|
||||||
|
<div class="relative flex justify-center">
|
||||||
|
<span class="px-4 bg-white text-sm text-gray-500">Datos de contacto</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Datos de Contacto -->
|
||||||
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4 w-1/3">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Email
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
||||||
|
</svg>
|
||||||
|
<input type="email" name="email" required
|
||||||
|
value="{{ old('email', $user->email ?? '') }}"
|
||||||
|
class="w-[300px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4">
|
||||||
|
<label class="block text-sm font-medium text-gray-700">
|
||||||
|
Teléfono
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
|
||||||
|
</svg>
|
||||||
|
<input type="tel" name="phone"
|
||||||
|
value="{{ old('phone', $user->phone ?? '') }}"
|
||||||
|
class="w-[250px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4 align-top">
|
||||||
|
<label class="block text-sm font-medium text-gray-700">
|
||||||
|
Dirección
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="flex items-start gap-2">
|
||||||
|
<svg class="w-5 h-5 text-gray-400 mt-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/>
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/>
|
||||||
|
</svg>
|
||||||
|
<textarea name="address" rows="3"
|
||||||
|
class="w-full border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">{{ old('address', $user->address ?? '') }}</textarea>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Separador -->
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-0 flex items-center">
|
||||||
|
<div class="w-full border-t border-gray-300"></div>
|
||||||
|
</div>
|
||||||
|
<div class="relative flex justify-center">
|
||||||
|
<span class="px-4 bg-white text-sm text-gray-500">Otros datos</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Datos de Contacto -->
|
||||||
|
<div class="bg-white py-6">
|
||||||
|
<table class="w-full">
|
||||||
|
<tbody>
|
||||||
|
<!-- Estado -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4 w-1/3">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Estado
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<select name="is_active" class="w-[200px] border-b-1 border-gray-300 focus:border-blue-500 focus:outline-none">
|
||||||
|
<option value="Activo">Activo</option>
|
||||||
|
<option value="Inactivo">Inactivo</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Foto -->
|
||||||
|
<tr>
|
||||||
|
<td class="py-2 pr-4">
|
||||||
|
<label class="block text-sm font-bold text-gray-700">
|
||||||
|
Foto
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td class="py-2">
|
||||||
|
<div class="mb-6">
|
||||||
|
|
||||||
|
@livewire('image-uploader', [
|
||||||
|
'fieldName' => 'profile_photo_path',
|
||||||
|
'currentImage' => $user->profile_photo_path ?? null,
|
||||||
|
'placeholder' => asset('images/default-user.png')
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>php
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botón de envío -->
|
||||||
|
<div class="text-right">
|
||||||
|
<button type="submit"
|
||||||
|
class="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors">
|
||||||
|
{{ isset($user) ? 'Actualizar Usuario' : 'Crear Usuario' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function generatePassword() {
|
||||||
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()';
|
||||||
|
let password = '';
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
password += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||||
|
}
|
||||||
|
document.getElementById('password').value = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
<div class="mt-2 flex items-center gap-2">
|
||||||
|
<input type="checkbox" onclick="togglePasswordVisibility()">
|
||||||
|
<span class="text-sm text-gray-500">Mostrar contraseña</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
function togglePasswordVisibility() {
|
||||||
|
const passwordField = document.getElementById('password');
|
||||||
|
passwordField.type = passwordField.type === 'password' ? 'text' : 'password';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</x-layouts.app>
|
||||||
17
resources/views/users/index.blade.php
Normal file
17
resources/views/users/index.blade.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<x-layouts.app :title="__('Users')">
|
||||||
|
<div class="max-w-7xl mx-auto px-4 py-8">
|
||||||
|
<div class="flex justify-between items-center mb-6">
|
||||||
|
<div class="flex items-center gap-4 mb-4">
|
||||||
|
<svg class="w-8 h-8 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
||||||
|
</svg>
|
||||||
|
<h1 class="text-3xl font-bold text-gray-800">Usuarios</h1>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('users.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
|
||||||
|
Nuevo
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@livewire('user-table')
|
||||||
|
</div>
|
||||||
|
</x-layouts.app>
|
||||||
259
resources/views/users/show.blade.php
Normal file
259
resources/views/users/show.blade.php
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
<x-layouts.app :title="__('Show User')">
|
||||||
|
|
||||||
|
<div class="container mx-auto px-4 py-6">
|
||||||
|
<!-- Header Section -->
|
||||||
|
<div class="bg-white rounded-lg shadow-md p-6 mb-6 flex items-center justify-between">
|
||||||
|
<!-- User Info Left -->
|
||||||
|
<div class="flex items-center space-x-6">
|
||||||
|
<!-- User Photo -->
|
||||||
|
<img src="{{ $user->photo_url ?? 'https://via.placeholder.com/150' }}"
|
||||||
|
class="w-24 h-24 rounded-full object-cover border-4 border-blue-100">
|
||||||
|
|
||||||
|
<!-- User Details -->
|
||||||
|
<div>
|
||||||
|
<h1 class="text-2xl font-bold text-gray-700">
|
||||||
|
{{ $user->first_name }} {{ $user->last_name }}
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<!-- Contact Info -->
|
||||||
|
<div class="mt-2 space-y-1">
|
||||||
|
<div class="flex items-center text-gray-600">
|
||||||
|
<p class="text-sm text-gray-700">
|
||||||
|
{{ $user->first_name }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center text-gray-600">
|
||||||
|
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"/>
|
||||||
|
</svg>
|
||||||
|
<a href="mailto:{{ $user->email }}" class="hover:text-blue-600">
|
||||||
|
{{ $user->email }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($user->phone)
|
||||||
|
<div class="flex items-center text-gray-600">
|
||||||
|
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/>
|
||||||
|
</svg>
|
||||||
|
<a href="tel:{{ $user->phone }}" class="hover:text-blue-600">
|
||||||
|
{{ $user->phone }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Right Section -->
|
||||||
|
<div class="flex flex-col items-end space-y-4">
|
||||||
|
<!-- Navigation Toolbar -->
|
||||||
|
<div class="flex space-x-2">
|
||||||
|
<a href="{{ route('users.index') }}"
|
||||||
|
class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg flex items-center">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
@if($previousUser)
|
||||||
|
<a href="{{ route('users.show', $previousUser) }}" class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg flex items-center">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($nextUser)
|
||||||
|
<a href="{{ route('users.show', $nextUser) }}"
|
||||||
|
class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg flex items-center">
|
||||||
|
<svg class="w-4 h-4 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Status Badge -->
|
||||||
|
<span class="px-4 py-2 w-30 rounded-lg text-sm text-center font-semibold
|
||||||
|
{{ $user->is_active ? 'bg-green-200 text-green-800' : 'bg-red-100 text-red-800' }}">
|
||||||
|
{{ $user->is_active ? 'Activo' : 'Inactivo' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tab Bar -->
|
||||||
|
<div x-data="{ activeTab: 'info' }" class="bg-white rounded-lg shadow-md">
|
||||||
|
<!-- Tab Headers -->
|
||||||
|
<div class="border-b border-gray-200">
|
||||||
|
<nav class="flex space-x-8 px-6">
|
||||||
|
<button @click="activeTab = 'info'"
|
||||||
|
:class="activeTab === 'info' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
|
||||||
|
class="py-4 px-1 border-b-2 font-medium">
|
||||||
|
Información del Usuario
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button @click="activeTab = 'permissions'"
|
||||||
|
:class="activeTab === 'permissions' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
|
||||||
|
class="py-4 px-1 border-b-2 font-medium">
|
||||||
|
Permisos
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button @click="activeTab = 'projects'"
|
||||||
|
:class="activeTab === 'projects' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
|
||||||
|
class="py-4 px-1 border-b-2 font-medium">
|
||||||
|
Proyectos
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tab Content -->
|
||||||
|
<div class="p-6">
|
||||||
|
<!-- Info Tab -->
|
||||||
|
<div x-show="activeTab === 'info'">
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
|
<tbody class="bg-white divide-y divide-gray-200">
|
||||||
|
@foreach(['name' => 'Nombre', 'last_name' => 'Apellido', 'email' => 'Email', 'phone' => 'Teléfono', 'created_at' => 'Fecha Registro'] as $field => $label)
|
||||||
|
<tr>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{{ $label }}</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
|
{{ $user->$field ?? 'N/A' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="mt-6 flex space-x-4">
|
||||||
|
<a href="{{ route('users.edit', $user) }}"
|
||||||
|
class="px-4 py-2 w-[150px] bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/>
|
||||||
|
</svg>
|
||||||
|
Editar
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{{-- Formulario de Edición --}}
|
||||||
|
<form method="POST" action="{{ route('users.update', $user) }}">
|
||||||
|
@csrf
|
||||||
|
@method('PUT') <!-- Important! -->
|
||||||
|
<button type="submit"
|
||||||
|
class="px-4 py-2 w-[150px] {{ $user->is_active ? 'bg-red-600 hover:bg-red-700' : 'bg-green-600 hover:bg-green-700' }} text-white rounded-lg flex items-center">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
|
||||||
|
</svg>
|
||||||
|
{{ $user->is_active ? 'Desactivar' : 'Activar' }}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{-- Formulario de Eliminación --}}
|
||||||
|
<form method="POST" action="{{ route('users.destroy', $user) }}">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE') <!-- Important! -->
|
||||||
|
<button type="submit"
|
||||||
|
onclick="return confirm('¿Estás seguro de querer eliminar este usuario?')"
|
||||||
|
class="px-4 py-2 w-[150px] bg-red-600 hover:bg-red-700 text-white rounded-lg flex items-center">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||||
|
</svg>
|
||||||
|
Eliminar
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Permissions Tab -->
|
||||||
|
<div x-show="activeTab === 'permissions'" x-cloak>
|
||||||
|
<div class="space-y-6">
|
||||||
|
@foreach($permissionGroups as $group => $permissions)
|
||||||
|
<div class="border rounded-lg p-4">
|
||||||
|
<h3 class="text-lg font-semibold mb-4">{{ ucfirst($group) }}</h3>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
@foreach($permissions as $permission)
|
||||||
|
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
|
||||||
|
<span class="text-sm">{{ $permission->name }}</span>
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox"
|
||||||
|
@if($user->hasPermissionTo($permission)) checked @endif
|
||||||
|
wire:change="togglePermission('{{ $permission->name }}')">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Nueva Pestaña de Proyectos -->
|
||||||
|
<div x-show="activeTab === 'projects'" x-cloak>
|
||||||
|
<div class="space-y-6">
|
||||||
|
<!-- Proyectos Actuales -->
|
||||||
|
<div class="border rounded-lg p-4">
|
||||||
|
<h3 class="text-lg font-semibold mb-4">Proyectos Asociados</h3>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
falta implementar
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Añadir Proyectos (Solo con permisos) -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.switch {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
width: 60px;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch input {
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider {
|
||||||
|
position: absolute;
|
||||||
|
cursor: pointer;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #ccc;
|
||||||
|
transition: .4s;
|
||||||
|
border-radius: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider:before {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
height: 26px;
|
||||||
|
width: 26px;
|
||||||
|
left: 4px;
|
||||||
|
bottom: 4px;
|
||||||
|
background-color: white;
|
||||||
|
transition: .4s;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + .slider {
|
||||||
|
background-color: #3B82F6;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + .slider:before {
|
||||||
|
transform: translateX(26px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</x-layouts.app>
|
||||||
@@ -34,12 +34,24 @@ require __DIR__.'/auth.php';
|
|||||||
Route::middleware(['auth', 'verified'])->group(function () {
|
Route::middleware(['auth', 'verified'])->group(function () {
|
||||||
// Dashboard
|
// Dashboard
|
||||||
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||||
|
|
||||||
|
// Usuarios:
|
||||||
|
Route::get('users/{user}/edit', [UserController::class, 'edit'])->name('users.edit');
|
||||||
|
Route::get('/users/create', [UserController::class, 'create'])->name('users.create')->middleware('can:create-users');
|
||||||
|
// Procesar creación de usuario
|
||||||
|
Route::post('/users', [UserController::class, 'store'])->name('users.store')->middleware('can:create-users');
|
||||||
|
Route::put('/usuarios/{user}', [UserController::class, 'update'])->name('users.update')->middleware('can:update,user'); // Opcional: si usas políticas
|
||||||
|
Route::post('/users', [UserController::class, 'store'])->name('users.store');
|
||||||
|
Route::put('users/{user}', [UserController::class, 'update'])->name('users.update');
|
||||||
|
Route::patch('users/{user}', [UserController::class, 'update']);
|
||||||
|
Route::delete('users/{user}', [UserController::class, 'destroy'])->name('users.destroy');
|
||||||
|
Route::get('users/{user}', [UserController::class, 'show'])->name('users.show');
|
||||||
|
|
||||||
// Proyectos
|
// Proyectos
|
||||||
Route::resource('projects', ProjectController::class);
|
Route::resource('projects', ProjectController::class);
|
||||||
Route::get('/projects/{project}', ProjectController::class)->name('projects.show');
|
Route::get('/projects/{project}', ProjectController::class)->name('projects.show');
|
||||||
Route::get('/projects/{project}', ProjectController::class)->name('projects.show')->middleware('can:view,project'); // Opcional: política de acceso
|
//Route::get('/projects/{project}', ProjectController::class)->name('projects.show')->middleware('can:view,project'); // Opcional: política de acceso
|
||||||
Route::get('/projects/{project}', ProjectShow::class)->name('projects.show');
|
//Route::get('/projects/{project}', ProjectShow::class)->name('projects.show');
|
||||||
|
|
||||||
|
|
||||||
// Documentos
|
// Documentos
|
||||||
|
|||||||
Reference in New Issue
Block a user