añadir funicionalidades de permisos y grupos
This commit is contained in:
@@ -57,4 +57,4 @@ php artisan migrate --seed
|
|||||||
php artisan storage:link
|
php artisan storage:link
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
php artisan serve
|
composer run dev
|
||||||
@@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
abstract class Controller
|
abstract class Controller
|
||||||
{
|
{
|
||||||
//
|
use AuthorizesRequests, ValidatesRequests; // <-- Traits esenciales
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Models\Folder;
|
use App\Models\Folder;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use App\Rules\UniqueFolderName;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
class FolderController extends Controller
|
class FolderController extends Controller
|
||||||
{
|
{
|
||||||
@@ -50,9 +54,51 @@ class FolderController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Folder $folder)
|
public function update(Folder $folder, Request $request)
|
||||||
{
|
{
|
||||||
//
|
try {
|
||||||
|
// Verificar permisos
|
||||||
|
if (!Gate::allows('update', $folder)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No tienes permisos para modificar esta carpeta'
|
||||||
|
], Response::HTTP_FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validación
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'name' => [
|
||||||
|
'required',
|
||||||
|
'max:255',
|
||||||
|
new UniqueFolderName(
|
||||||
|
$folder->project_id,
|
||||||
|
$folder->parent_id
|
||||||
|
)
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $validator->errors()
|
||||||
|
], Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualizar nombre
|
||||||
|
$folder->update(['name' => $request->name]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Carpeta actualizada',
|
||||||
|
'folder' => $folder
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Error al actualizar carpeta: ' . $e->getMessage()
|
||||||
|
], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,6 +106,91 @@ class FolderController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Folder $folder)
|
public function destroy(Folder $folder)
|
||||||
{
|
{
|
||||||
//
|
try {
|
||||||
|
// Verificar permisos
|
||||||
|
if (!Gate::allows('delete', $folder)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No tienes permisos para eliminar esta carpeta'
|
||||||
|
], Response::HTTP_FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validar que esté vacía
|
||||||
|
if ($folder->documents()->exists() || $folder->children()->exists()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No puedes eliminar carpetas con contenido'
|
||||||
|
], Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Eliminar
|
||||||
|
$folder->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Carpeta eliminada'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Error al eliminar carpeta: ' . $e->getMessage()
|
||||||
|
], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the specified folder to a new location.
|
||||||
|
*/
|
||||||
|
public function move(Folder $folder, Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Verificar permisos
|
||||||
|
if (!Gate::allows('move', $folder)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No tienes permisos para esta acción'
|
||||||
|
], Response::HTTP_FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validación
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'parent_id' => 'nullable|exists:folders,id',
|
||||||
|
'project_id' => 'required|exists:projects,id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $validator->errors()
|
||||||
|
], Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevenir movimiento a sí mismo o descendientes
|
||||||
|
if ($request->parent_id && $folder->isDescendantOf($request->parent_id)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No puedes mover una carpeta a su propia jerarquía'
|
||||||
|
], Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualizar ubicación
|
||||||
|
$folder->update([
|
||||||
|
'parent_id' => $request->parent_id,
|
||||||
|
'project_id' => $request->project_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Carpeta movida exitosamente',
|
||||||
|
'folder' => $folder->fresh()
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Error al mover la carpeta: ' . $e->getMessage()
|
||||||
|
], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
65
app/Http/Controllers/GroupController.php
Normal file
65
app/Http/Controllers/GroupController.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Group;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class GroupController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Group $group)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Group $group)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Group $group)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Group $group)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; // <-- Asegúrate de tener esta línea
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
use Spatie\Permission\Models\Permission;
|
use Spatie\Permission\Models\Permission;
|
||||||
@@ -12,24 +13,36 @@ class RoleController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->authorize('viewAny', Role::class);
|
$this->authorize('viewAny', Role::class);
|
||||||
|
|
||||||
$roles = Role::withCount('users')->paginate(10);
|
$roles = Role::withCount('users')->paginate(10);
|
||||||
return view('roles.index', compact('roles'));
|
return view('roles.index', compact('roles'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$this->authorize('create', Role::class);
|
$this->authorize('create roles');
|
||||||
$permissions = Permission::all()->groupBy('group');
|
$permissions = Permission::all(['id', 'name']);
|
||||||
return view('roles.create', compact('permissions'));
|
return view('roles.create', compact('permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(StoreRoleRequest $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$role = Role::create($request->only('name'));
|
/*$role = Role::create($request->only('name'));
|
||||||
$role->syncPermissions($request->permissions);
|
$role->syncPermissions($request->permissions);
|
||||||
|
|
||||||
return redirect()->route('roles.index')
|
return redirect()->route('roles.index')
|
||||||
->with('success', 'Rol creado exitosamente');
|
->with('success', 'Rol creado exitosamente');*/
|
||||||
|
|
||||||
|
$this->authorize('create', Role::class);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|unique:roles',
|
||||||
|
'description' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
Role::create($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('roles.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(Role $role)
|
public function edit(Role $role)
|
||||||
@@ -41,7 +54,7 @@ class RoleController extends Controller
|
|||||||
return view('roles.edit', compact('role', 'permissions', 'rolePermissions'));
|
return view('roles.edit', compact('role', 'permissions', 'rolePermissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(StoreRoleRequest $request, Role $role)
|
public function update(Request $request, Role $role)
|
||||||
{
|
{
|
||||||
$role->update($request->only('name'));
|
$role->update($request->only('name'));
|
||||||
$role->syncPermissions($request->permissions);
|
$role->syncPermissions($request->permissions);
|
||||||
|
|||||||
27
app/Http/Middleware/CheckResourcePermissions.php
Normal file
27
app/Http/Middleware/CheckResourcePermissions.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class CheckResourcePermissions
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle($request, $next, $permission)
|
||||||
|
{
|
||||||
|
$resource = $request->route()->parameter('project')
|
||||||
|
?? $request->route()->parameter('folder');
|
||||||
|
|
||||||
|
if (!$request->user()->hasPermissionToResource($resource, $permission)) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/Livewire/FileUpload.php
Normal file
82
app/Livewire/FileUpload.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Folder;
|
||||||
|
|
||||||
|
class FileUpload extends Component
|
||||||
|
{
|
||||||
|
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
|
public Project $project;
|
||||||
|
public Folder|null $folder;
|
||||||
|
public $files = [];
|
||||||
|
public $previews = [];
|
||||||
|
public $maxSize = 50; // MB
|
||||||
|
public $folderId;
|
||||||
|
|
||||||
|
protected $listeners = ['folderChanged' => 'updateFolder'];
|
||||||
|
|
||||||
|
public function updateFolder($folderId)
|
||||||
|
{
|
||||||
|
$this->folder = Folder::find($folderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedFiles()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'files.*' => "max:{$this->maxSize}1024|mimes:pdf,docx,xlsx,jpg,png,svg",
|
||||||
|
'folderId' => 'required|exists:folders,id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->previews = [];
|
||||||
|
foreach ($this->files as $file) {
|
||||||
|
$this->previews[] = [
|
||||||
|
'name' => $file->getClientOriginalName(),
|
||||||
|
'type' => $file->getMimeType(),
|
||||||
|
'size' => $file->getSize(),
|
||||||
|
'preview' => str_starts_with($file->getMimeType(), 'image/')
|
||||||
|
? $file->temporaryUrl()
|
||||||
|
: null
|
||||||
|
];
|
||||||
|
|
||||||
|
Document::create([
|
||||||
|
'name' => $file->getClientOriginalName(),
|
||||||
|
'file_path' => $file->store("projects/{$this->folderId}"),
|
||||||
|
'folder_id' => $this->folderId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'files.*' => "required|max:{$this->maxSize}1024|mimes:pdf,docx,xlsx,jpg,png,svg"
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($this->files as $file) {
|
||||||
|
$path = $file->store("projects/{$this->project->id}/documents", 'public');
|
||||||
|
|
||||||
|
$this->project->documents()->create([
|
||||||
|
'name' => $file->getClientOriginalName(),
|
||||||
|
'file_path' => $path,
|
||||||
|
'folder_id' => $this->folder?->id,
|
||||||
|
'size' => $file->getSize(),
|
||||||
|
'type' => $file->getMimeType()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->reset(['files', 'previews']);
|
||||||
|
$this->emit('documentsUpdated');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.file-upload');
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Livewire/GroupSearch.php
Normal file
13
app/Livewire/GroupSearch.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class GroupSearch extends Component
|
||||||
|
{
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.group-search');
|
||||||
|
}
|
||||||
|
}
|
||||||
101
app/Livewire/PermissionManager.php
Normal file
101
app/Livewire/PermissionManager.php
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Folder;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class PermissionManager extends Component
|
||||||
|
{
|
||||||
|
public $selectedProject;
|
||||||
|
public $selectedFolder;
|
||||||
|
public $assignTo = 'user';
|
||||||
|
public $selectedPermissions = [];
|
||||||
|
public $selectedUser;
|
||||||
|
public $selectedGroup;
|
||||||
|
|
||||||
|
protected $listeners = ['userSelected', 'groupSelected'];
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'selectedProject' => 'required|exists:projects,id',
|
||||||
|
'selectedFolder' => 'nullable|exists:folders,id',
|
||||||
|
'selectedPermissions' => 'required|array|min:1',
|
||||||
|
'selectedUser' => 'required_if:assignTo,user',
|
||||||
|
'selectedGroup' => 'required_if:assignTo,group',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSelectedResourceIdProperty()
|
||||||
|
{
|
||||||
|
return $this->selectedFolder ?: $this->selectedProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCanSaveProperty()
|
||||||
|
{
|
||||||
|
return $this->selectedProject &&
|
||||||
|
($this->assignTo === 'group' ? $this->selectedGroup : $this->selectedUser) &&
|
||||||
|
count($this->selectedPermissions) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProjectsProperty()
|
||||||
|
{
|
||||||
|
return Project::accessibleBy(auth()->user())->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFoldersProperty()
|
||||||
|
{
|
||||||
|
if (!$this->selectedProject) return collect();
|
||||||
|
|
||||||
|
return Folder::where('project_id', $this->selectedProject)
|
||||||
|
->withDepth()
|
||||||
|
->get()
|
||||||
|
->toTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPermissionsProperty()
|
||||||
|
{
|
||||||
|
$type = $this->selectedFolder ? 'folder' : 'project';
|
||||||
|
return config("permissions.types.$type", []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userSelected($userId)
|
||||||
|
{
|
||||||
|
$this->selectedUser = $userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function groupSelected($groupId)
|
||||||
|
{
|
||||||
|
$this->selectedGroup = $groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function savePermissions()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
|
||||||
|
$model = $this->assignTo === 'user'
|
||||||
|
? User::find($this->selectedUser)
|
||||||
|
: Group::find($this->selectedGroup);
|
||||||
|
|
||||||
|
$resource = $this->selectedFolder
|
||||||
|
? Folder::find($this->selectedFolder)
|
||||||
|
: Project::find($this->selectedProject);
|
||||||
|
|
||||||
|
// Asignar permisos usando Spatie
|
||||||
|
$model->givePermissionTo(
|
||||||
|
$resource->permissions()->whereIn('name', $this->selectedPermissions)->get()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->reset(['selectedPermissions']);
|
||||||
|
$this->dispatch('permissionsUpdated');
|
||||||
|
session()->flash('message', 'Permisos actualizados correctamente.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.permission-manager');
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/Livewire/PermissionsList.php
Normal file
59
app/Livewire/PermissionsList.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use App\Models\{User, Group};
|
||||||
|
|
||||||
|
class PermissionsList extends Component
|
||||||
|
{
|
||||||
|
public $resourceId;
|
||||||
|
public $resourceType;
|
||||||
|
|
||||||
|
public function mount($resourceId)
|
||||||
|
{
|
||||||
|
$this->resourceId = $resourceId;
|
||||||
|
$this->determineResourceType();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function determineResourceType()
|
||||||
|
{
|
||||||
|
if (Project::find($this->resourceId)) {
|
||||||
|
$this->resourceType = 'project';
|
||||||
|
} else {
|
||||||
|
$this->resourceType = 'folder';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPermissions()
|
||||||
|
{
|
||||||
|
return Permission::where('name', 'like', "{$this->resourceType}-{$this->resourceId}-%")
|
||||||
|
->get()
|
||||||
|
->groupBy(function ($permission) {
|
||||||
|
return explode('-', $permission->name)[2]; // Obtener tipo de permiso
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revokePermission($permissionId, $modelType, $modelId)
|
||||||
|
{
|
||||||
|
$permission = Permission::findOrFail($permissionId);
|
||||||
|
|
||||||
|
$model = $modelType === 'user'
|
||||||
|
? User::find($modelId)
|
||||||
|
: Group::find($modelId);
|
||||||
|
|
||||||
|
$model->revokePermissionTo($permission);
|
||||||
|
|
||||||
|
$this->dispatch('permissionsUpdated');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.permissions-list', [
|
||||||
|
'permissions' => $this->getPermissions(),
|
||||||
|
'users' => User::withPermissionsForResource($this->resourceId, $this->resourceType)->get(),
|
||||||
|
'groups' => Group::withPermissionsForResource($this->resourceId, $this->resourceType)->get()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,28 +3,40 @@
|
|||||||
namespace App\Livewire;
|
namespace App\Livewire;
|
||||||
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Livewire\Attributes\Title;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Folder;
|
use App\Models\Folder;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class ProjectShow extends Component
|
class ProjectShow extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
public Project $project;
|
public Project $project;
|
||||||
public $selectedFolderId = null;
|
public ?Folder $currentFolder = null;
|
||||||
public $expandedFolders = [];
|
public $expandedFolders = [];
|
||||||
|
public $files = [];
|
||||||
|
public $folderName = '';
|
||||||
|
|
||||||
|
public $selectedFolderId = null;
|
||||||
|
|
||||||
|
|
||||||
public function mount(Project $project)
|
public function mount(Project $project)
|
||||||
{
|
{
|
||||||
$this->project = $project->load('rootFolders');
|
$this->project = $project->load('rootFolders');
|
||||||
|
$this->currentFolder = $this->project->rootFolders->first() ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectFolder($folderId)
|
public function selectFolder($folderId)
|
||||||
{
|
{
|
||||||
$this->selectedFolderId = $folderId;
|
$this->selectedFolderId = $folderId;
|
||||||
|
$this->currentFolder = Folder::with('children')->find($folderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleFolder($folderId)
|
public function toggleFolder($folderId): void
|
||||||
{
|
{
|
||||||
if (in_array($folderId, $this->expandedFolders)) {
|
if (in_array($folderId, $this->expandedFolders)) {
|
||||||
$this->expandedFolders = array_diff($this->expandedFolders, [$folderId]);
|
$this->expandedFolders = array_diff($this->expandedFolders, [$folderId]);
|
||||||
@@ -33,18 +45,82 @@ class ProjectShow extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createFolder(): void
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'folderName' => [
|
||||||
|
'required',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('folders', 'name')->where(function ($query) {
|
||||||
|
return $query->where('project_id', $this->project->id)
|
||||||
|
->where('parent_id', $this->currentFolder?->id);
|
||||||
|
})
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
Folder::create([
|
||||||
|
'name' => $this->folderName,
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'parent_id' => $this->currentFolder?->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->reset('folderName');
|
||||||
|
$this->project->load('rootFolders'); // Recargar carpetas raíz
|
||||||
|
if ($this->currentFolder) {
|
||||||
|
$this->currentFolder->load('children'); // Recargar hijos si está en una subcarpeta
|
||||||
|
}
|
||||||
|
$this->project->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadFiles(): void
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'files.*' => 'file|max:10240|mimes:pdf,docx,xlsx,jpg,png'
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($this->files as $file) {
|
||||||
|
Document::create([
|
||||||
|
'name' => $file->getClientOriginalName(),
|
||||||
|
'file_path' => $file->store("projects/{$this->project->id}/documents"),
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'folder_id' => $this->currentFolder?->id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->reset('files');
|
||||||
|
if ($this->currentFolder) {
|
||||||
|
$this->currentFolder->refresh(); // Recargar documentos
|
||||||
|
}
|
||||||
|
$this->reset('files');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDocumentsProperty()
|
public function getDocumentsProperty()
|
||||||
{
|
{
|
||||||
return Document::where('folder_id', $this->selectedFolderId)
|
return $this->currentFolder
|
||||||
->where('project_id', $this->project->id)
|
? $this->currentFolder->documents()->with('versions')->get()
|
||||||
->with('versions')
|
: Document::whereNull('folder_id')->where('project_id', $this->project->id)->with('versions')->get();
|
||||||
->get();
|
}
|
||||||
|
|
||||||
|
public function getBreadcrumbsProperty()
|
||||||
|
{
|
||||||
|
if (!$this->currentFolder) return collect();
|
||||||
|
|
||||||
|
$breadcrumbs = collect();
|
||||||
|
$folder = $this->currentFolder;
|
||||||
|
|
||||||
|
while ($folder) {
|
||||||
|
$breadcrumbs->prepend($folder);
|
||||||
|
$folder = $folder->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $breadcrumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.project-show', [
|
return view('livewire.project-show')
|
||||||
'rootFolders' => $this->project->rootFolders
|
->layout('layouts.livewire-app', [
|
||||||
|
'title' => $this->project->name
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
app/Livewire/Toolbar.php
Normal file
25
app/Livewire/Toolbar.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Folder;
|
||||||
|
|
||||||
|
class Toolbar extends Component
|
||||||
|
{
|
||||||
|
|
||||||
|
public Project $project;
|
||||||
|
public ?Folder $currentFolder;
|
||||||
|
|
||||||
|
public function mount(Project $project, Folder $currentFolder = null)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
$this->currentFolder = $currentFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.toolbar');
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Livewire/UserSearch.php
Normal file
28
app/Livewire/UserSearch.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class UserSearch extends Component
|
||||||
|
{
|
||||||
|
public $search = '';
|
||||||
|
public $selectedUser;
|
||||||
|
|
||||||
|
public function selectUser($userId)
|
||||||
|
{
|
||||||
|
$this->selectedUser = $userId;
|
||||||
|
$this->emitUp('userSelected', $userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$users = User::query()
|
||||||
|
->when($this->search, fn($q) => $q->where('name', 'like', "%{$this->search}%"))
|
||||||
|
->limit(5)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('livewire.user-search', compact('users'));
|
||||||
|
}
|
||||||
|
}
|
||||||
176
app/Models/Group.php
Normal file
176
app/Models/Group.php
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Spatie\Permission\Traits\HasPermissions;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class Group extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes, HasPermissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'description'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accessors to append to the model's array form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $appends = ['permission_names'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relationship: Users belonging to this group
|
||||||
|
*/
|
||||||
|
public function users(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(User::class)
|
||||||
|
->withTimestamps()
|
||||||
|
->using(GroupUser::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relationship: Permissions assigned to this group
|
||||||
|
*/
|
||||||
|
public function permissions(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(
|
||||||
|
config('permission.models.permission'),
|
||||||
|
config('permission.table_names.group_has_permissions'),
|
||||||
|
'group_id',
|
||||||
|
'permission_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope: Groups with specific permission
|
||||||
|
*/
|
||||||
|
public function scopeWithPermission(Builder $query, $permission): Builder
|
||||||
|
{
|
||||||
|
return $query->whereHas('permissions', function ($q) use ($permission) {
|
||||||
|
$q->where('name', $permission);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope: Groups with permissions on specific resource
|
||||||
|
*/
|
||||||
|
public function scopeWithResourcePermissions(Builder $query, $resourceId, $resourceType): Builder
|
||||||
|
{
|
||||||
|
return $query->whereHas('permissions', function ($q) use ($resourceId, $resourceType) {
|
||||||
|
$q->where('name', 'like', "{$resourceType}-{$resourceId}-%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign permission to group
|
||||||
|
*/
|
||||||
|
public function assignPermission($permission): self
|
||||||
|
{
|
||||||
|
if (is_string($permission)) {
|
||||||
|
$permission = Permission::findByName($permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->permissions()->syncWithoutDetaching($permission);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Revoke permission from group
|
||||||
|
*/
|
||||||
|
public function revokePermission($permission): self
|
||||||
|
{
|
||||||
|
if (is_string($permission)) {
|
||||||
|
$permission = Permission::findByName($permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->permissions()->detach($permission);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync all permissions
|
||||||
|
*/
|
||||||
|
public function syncPermissions($permissions): self
|
||||||
|
{
|
||||||
|
$permissionIds = collect($permissions)->map(function ($perm) {
|
||||||
|
return is_string($perm) ? Permission::findByName($perm)->id : $perm->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->permissions()->sync($permissionIds);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if group has permission
|
||||||
|
*/
|
||||||
|
public function hasPermission($permission): bool
|
||||||
|
{
|
||||||
|
if (is_string($permission)) {
|
||||||
|
return $this->permissions->contains('name', $permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->permissions->contains('id', $permission->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all users with permissions through this group
|
||||||
|
*/
|
||||||
|
public function getUsersWithPermissionsAttribute()
|
||||||
|
{
|
||||||
|
return User::whereHas('groups', function ($query) {
|
||||||
|
$query->where('groups.id', $this->id);
|
||||||
|
})->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get permission names attribute
|
||||||
|
*/
|
||||||
|
public function getPermissionNamesAttribute()
|
||||||
|
{
|
||||||
|
return $this->permissions->pluck('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*/
|
||||||
|
public static function validationRules($groupId = null): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required|string|max:255|unique:groups,name,'.$groupId,
|
||||||
|
'description' => 'nullable|string|max:500',
|
||||||
|
'permissions' => 'array',
|
||||||
|
'permissions.*' => 'exists:permissions,id',
|
||||||
|
'users' => 'array',
|
||||||
|
'users.*' => 'exists:users,id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::deleting(function ($group) {
|
||||||
|
if ($group->isForceDeleting()) {
|
||||||
|
$group->users()->detach();
|
||||||
|
$group->permissions()->detach();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,11 @@ class Project extends Model
|
|||||||
return $this->hasMany(Folder::class);
|
return $this->hasMany(Folder::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function currentFolder()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Folder::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function documents() {
|
public function documents() {
|
||||||
return $this->hasMany(Document::class);
|
return $this->hasMany(Document::class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
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\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -12,8 +13,7 @@ use Spatie\Permission\Traits\HasRoles;
|
|||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable, HasRoles, SoftDeletes;
|
||||||
use HasRoles;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
@@ -60,4 +60,34 @@ class User extends Authenticatable
|
|||||||
->map(fn (string $name) => Str::of($name)->substr(0, 1))
|
->map(fn (string $name) => Str::of($name)->substr(0, 1))
|
||||||
->implode('');
|
->implode('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function groups()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Group::class)
|
||||||
|
->withTimestamps()
|
||||||
|
->using(GroupUser::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasPermissionThroughGroup($permission)
|
||||||
|
{
|
||||||
|
return $this->groups->flatMap(function ($group) {
|
||||||
|
return $group->permissions;
|
||||||
|
})->contains('name', $permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllPermissionsAttribute()
|
||||||
|
{
|
||||||
|
return $this->getAllPermissions()
|
||||||
|
->merge($this->groups->flatMap->permissions)
|
||||||
|
->unique('id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasAnyPermission($permissions): bool
|
||||||
|
{
|
||||||
|
return $this->hasPermissionTo($permissions) ||
|
||||||
|
$this->groups->contains(function ($group) use ($permissions) {
|
||||||
|
return $group->hasAnyPermission($permissions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ namespace App\Policies;
|
|||||||
|
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
use Illuminate\Auth\Access\Response;
|
use Illuminate\Auth\Access\Response;
|
||||||
|
|
||||||
class DocumentPolicy
|
class DocumentPolicy
|
||||||
{
|
{
|
||||||
|
use HandlesAuthorization;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the user can view any models.
|
* Determine whether the user can view any models.
|
||||||
*/
|
*/
|
||||||
@@ -22,7 +25,8 @@ class DocumentPolicy
|
|||||||
public function view(User $user, Document $document)
|
public function view(User $user, Document $document)
|
||||||
{
|
{
|
||||||
return $user->hasPermissionTo('view documents')
|
return $user->hasPermissionTo('view documents')
|
||||||
&& $user->hasProjectAccess($document->project_id);
|
&& $user->hasProjectAccess($document->project_id)
|
||||||
|
&& $user->hasPermissionToResource($document->resource(), 'view');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +42,7 @@ class DocumentPolicy
|
|||||||
*/
|
*/
|
||||||
public function update(User $user, Document $document): bool
|
public function update(User $user, Document $document): bool
|
||||||
{
|
{
|
||||||
return false;
|
return $user->hasPermissionToResource($document->resource(), 'edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +50,7 @@ class DocumentPolicy
|
|||||||
*/
|
*/
|
||||||
public function delete(User $user, Document $document): bool
|
public function delete(User $user, Document $document): bool
|
||||||
{
|
{
|
||||||
return false;
|
return $user->hasPermissionTo('delete documents');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
39
app/Policies/FolderPolicy.php
Normal file
39
app/Policies/FolderPolicy.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Folder;
|
||||||
|
|
||||||
|
class FolderPolicy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new policy instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(User $user, Folder $folder = null)
|
||||||
|
{
|
||||||
|
if ($folder) {
|
||||||
|
return $user->can('manage-projects') &&
|
||||||
|
$user->projects->contains($folder->project_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user->can('manage-projects');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function move(User $user, Folder $folder)
|
||||||
|
{
|
||||||
|
return $user->can('manage-projects') &&
|
||||||
|
$user->projects->contains($folder->project_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(User $user, Folder $folder)
|
||||||
|
{
|
||||||
|
return $user->can('delete-projects') &&
|
||||||
|
$user->projects->contains($folder->project_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,4 +75,9 @@ class ProjectPolicy
|
|||||||
$project->users->contains($user->id);
|
$project->users->contains($user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function managePermissions(User $user, Project $project)
|
||||||
|
{
|
||||||
|
return $user->hasPermissionToResource($project, 'manage_permissions');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
use App\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Auth\Access\Response;
|
use Illuminate\Auth\Access\Response;
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ class RolePolicy
|
|||||||
*/
|
*/
|
||||||
public function viewAny(User $user): bool
|
public function viewAny(User $user): bool
|
||||||
{
|
{
|
||||||
return $user->hasPermissionTo('manage roles');
|
return $user->hasPermissionTo('view roles');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +29,7 @@ class RolePolicy
|
|||||||
*/
|
*/
|
||||||
public function create(User $user): bool
|
public function create(User $user): bool
|
||||||
{
|
{
|
||||||
return $user->hasPermissionTo('manage roles');
|
return $user->hasPermissionTo('create roles');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +37,7 @@ class RolePolicy
|
|||||||
*/
|
*/
|
||||||
public function update(User $user, Role $role): bool
|
public function update(User $user, Role $role): bool
|
||||||
{
|
{
|
||||||
return $user->hasPermissionTo('manage roles') && !$role->is_protected;
|
return $user->hasPermissionTo('edit roles') && !$role->is_protected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +45,7 @@ class RolePolicy
|
|||||||
*/
|
*/
|
||||||
public function delete(User $user, Role $role): bool
|
public function delete(User $user, Role $role): bool
|
||||||
{
|
{
|
||||||
return $user->hasPermissionTo('manage roles') && !$role->is_protected;
|
return $user->hasPermissionTo('delete roles') && !$role->is_protected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,33 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Models\Document;
|
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Policies\DocumentPolicy;
|
|
||||||
use App\Policies\PermissionPolicy;
|
|
||||||
use App\Policies\ProfilePolicy;
|
|
||||||
use App\Policies\ProjectPolicy;
|
|
||||||
use App\Policies\RolePolicy;
|
|
||||||
use App\Policies\UserPolicy;
|
|
||||||
use Illuminate\Support\Facades\Blade;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
use Spatie\Permission\Models\Permission;
|
|
||||||
use Spatie\Permission\Models\Role;
|
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $policies = [
|
|
||||||
User::class => UserPolicy::class,
|
|
||||||
User::class => ProfilePolicy::class,
|
|
||||||
Role::class => RolePolicy::class,
|
|
||||||
Permission::class => PermissionPolicy::class,
|
|
||||||
Document::class => DocumentPolicy::class,
|
|
||||||
Project::class => ProjectPolicy::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any application services.
|
* Register any application services.
|
||||||
*/
|
*/
|
||||||
@@ -42,10 +23,23 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
// Configuración de componentes Blade
|
||||||
Blade::componentNamespace('App\\View\\Components', 'icons');
|
Blade::componentNamespace('App\\View\\Components', 'icons');
|
||||||
Blade::component('multiselect', \App\View\Components\Multiselect::class);
|
Blade::component('multiselect', \App\View\Components\Multiselect::class);
|
||||||
|
|
||||||
|
// Registro de componentes Livewire
|
||||||
Livewire::component('project-show', \App\Http\Livewire\ProjectShow::class);
|
Livewire::component('project-show', \App\Http\Livewire\ProjectShow::class);
|
||||||
|
Livewire::component('file-upload', \App\Http\Livewire\FileUpload::class);
|
||||||
|
Livewire::component('toolbar', \App\Http\Livewire\Toolbar::class);
|
||||||
|
|
||||||
|
// Validación personalizada
|
||||||
|
Validator::extend('max_upload_size', function ($attribute, $value, $parameters, $validator) {
|
||||||
|
$maxSize = env('MAX_UPLOAD_SIZE', 51200); // 50MB por defecto
|
||||||
|
$totalSize = array_reduce($value, function($sum, $file) {
|
||||||
|
return $sum + $file->getSize();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return $totalSize <= ($maxSize * 1024);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
66
app/Providers/AppServiceProvider.php.back
Normal file
66
app/Providers/AppServiceProvider.php.back
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
|
use App\Models\Folder;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Policies\DocumentPolicy;
|
||||||
|
use App\Policies\FolderPolicy;
|
||||||
|
use App\Policies\PermissionPolicy;
|
||||||
|
use App\Policies\ProfilePolicy;
|
||||||
|
use App\Policies\ProjectPolicy;
|
||||||
|
use App\Policies\RolePolicy;
|
||||||
|
use App\Policies\UserPolicy;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $policies = [
|
||||||
|
User::class => UserPolicy::class,
|
||||||
|
User::class => ProfilePolicy::class,
|
||||||
|
Role::class => RolePolicy::class,
|
||||||
|
Permission::class => PermissionPolicy::class,
|
||||||
|
Document::class => DocumentPolicy::class,
|
||||||
|
Project::class => ProjectPolicy::class,
|
||||||
|
Folder::class => FolderPolicy::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Blade::componentNamespace('App\\View\\Components', 'icons');
|
||||||
|
Blade::component('multiselect', \App\View\Components\Multiselect::class);
|
||||||
|
|
||||||
|
Livewire::component('project-show', \App\Http\Livewire\ProjectShow::class);
|
||||||
|
Livewire::component('project-show', \App\Http\Livewire\FileUpload::class);
|
||||||
|
Livewire::component('toolbar', \App\Http\Livewire\Toolbar::class);
|
||||||
|
|
||||||
|
Validator::extend('max_upload_size', function ($attribute, $value, $parameters, $validator) {
|
||||||
|
$maxSize = env('MAX_UPLOAD_SIZE', 51200); // Default 50MB
|
||||||
|
$totalSize = array_reduce($value, function($sum, $file) {
|
||||||
|
return $sum + $file->getSize();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return $totalSize <= ($maxSize * 1024);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
62
app/Providers/AuthServiceProvider.php
Normal file
62
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
//use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Document;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Folder;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use App\Policies\UserPolicy;
|
||||||
|
use App\Policies\DocumentPolicy;
|
||||||
|
use App\Policies\ProjectPolicy;
|
||||||
|
use App\Policies\FolderPolicy;
|
||||||
|
use App\Policies\RolePolicy;
|
||||||
|
use App\Policies\PermissionPolicy;
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The policy mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array<class-string, class-string>
|
||||||
|
*/
|
||||||
|
protected $policies = [
|
||||||
|
User::class => UserPolicy::class,
|
||||||
|
|
||||||
|
Project::class => ProjectPolicy::class,
|
||||||
|
Folder::class => FolderPolicy::class,
|
||||||
|
Document::class => DocumentPolicy::class,
|
||||||
|
|
||||||
|
Role::class => RolePolicy::class,
|
||||||
|
Permission::class => PermissionPolicy::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->registerPolicies();
|
||||||
|
|
||||||
|
// Configuración adicional de gates aquí si es necesario
|
||||||
|
Gate::before(function ($user, $ability) {
|
||||||
|
return $user->hasRole('admin') ? true : null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\AuthServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\VoltServiceProvider::class,
|
App\Providers\VoltServiceProvider::class,
|
||||||
];
|
];
|
||||||
|
|||||||
88
composer.lock
generated
88
composer.lock
generated
@@ -1137,16 +1137,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/framework",
|
"name": "laravel/framework",
|
||||||
"version": "v12.9.2",
|
"version": "v12.10.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/laravel/framework.git",
|
"url": "https://github.com/laravel/framework.git",
|
||||||
"reference": "3db59aa0f382c349c78a92f3e5b5522e00e3301b"
|
"reference": "0f123cc857bc177abe4d417448d4f7164f71802a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/laravel/framework/zipball/3db59aa0f382c349c78a92f3e5b5522e00e3301b",
|
"url": "https://api.github.com/repos/laravel/framework/zipball/0f123cc857bc177abe4d417448d4f7164f71802a",
|
||||||
"reference": "3db59aa0f382c349c78a92f3e5b5522e00e3301b",
|
"reference": "0f123cc857bc177abe4d417448d4f7164f71802a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1348,7 +1348,7 @@
|
|||||||
"issues": "https://github.com/laravel/framework/issues",
|
"issues": "https://github.com/laravel/framework/issues",
|
||||||
"source": "https://github.com/laravel/framework"
|
"source": "https://github.com/laravel/framework"
|
||||||
},
|
},
|
||||||
"time": "2025-04-16T15:44:19+00:00"
|
"time": "2025-04-24T14:11:20+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/prompts",
|
"name": "laravel/prompts",
|
||||||
@@ -1411,16 +1411,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/sanctum",
|
"name": "laravel/sanctum",
|
||||||
"version": "v4.0.8",
|
"version": "v4.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/laravel/sanctum.git",
|
"url": "https://github.com/laravel/sanctum.git",
|
||||||
"reference": "ec1dd9ddb2ab370f79dfe724a101856e0963f43c"
|
"reference": "4e4ced5023e9d8949214e0fb43d9f4bde79c7166"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/laravel/sanctum/zipball/ec1dd9ddb2ab370f79dfe724a101856e0963f43c",
|
"url": "https://api.github.com/repos/laravel/sanctum/zipball/4e4ced5023e9d8949214e0fb43d9f4bde79c7166",
|
||||||
"reference": "ec1dd9ddb2ab370f79dfe724a101856e0963f43c",
|
"reference": "4e4ced5023e9d8949214e0fb43d9f4bde79c7166",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1471,7 +1471,7 @@
|
|||||||
"issues": "https://github.com/laravel/sanctum/issues",
|
"issues": "https://github.com/laravel/sanctum/issues",
|
||||||
"source": "https://github.com/laravel/sanctum"
|
"source": "https://github.com/laravel/sanctum"
|
||||||
},
|
},
|
||||||
"time": "2025-01-26T19:34:36+00:00"
|
"time": "2025-04-22T13:53:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/serializable-closure",
|
"name": "laravel/serializable-closure",
|
||||||
@@ -2153,16 +2153,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "livewire/flux",
|
"name": "livewire/flux",
|
||||||
"version": "v2.1.4",
|
"version": "v2.1.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/livewire/flux.git",
|
"url": "https://github.com/livewire/flux.git",
|
||||||
"reference": "a19709fc94f5a1b795ce24ad42662bd398c19371"
|
"reference": "e24f05be20fa1a0ca027a11c2eea763cc539c82e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/livewire/flux/zipball/a19709fc94f5a1b795ce24ad42662bd398c19371",
|
"url": "https://api.github.com/repos/livewire/flux/zipball/e24f05be20fa1a0ca027a11c2eea763cc539c82e",
|
||||||
"reference": "a19709fc94f5a1b795ce24ad42662bd398c19371",
|
"reference": "e24f05be20fa1a0ca027a11c2eea763cc539c82e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -2210,9 +2210,9 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/livewire/flux/issues",
|
"issues": "https://github.com/livewire/flux/issues",
|
||||||
"source": "https://github.com/livewire/flux/tree/v2.1.4"
|
"source": "https://github.com/livewire/flux/tree/v2.1.5"
|
||||||
},
|
},
|
||||||
"time": "2025-04-14T11:59:19+00:00"
|
"time": "2025-04-24T22:52:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "livewire/livewire",
|
"name": "livewire/livewire",
|
||||||
@@ -3722,16 +3722,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/image",
|
"name": "spatie/image",
|
||||||
"version": "3.8.1",
|
"version": "3.8.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/spatie/image.git",
|
"url": "https://github.com/spatie/image.git",
|
||||||
"reference": "80e907bc64fbb7ce87346e97c14534d7dad5d559"
|
"reference": "54a7331a4d1ba7712603dd058522613506d2dfe0"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/spatie/image/zipball/80e907bc64fbb7ce87346e97c14534d7dad5d559",
|
"url": "https://api.github.com/repos/spatie/image/zipball/54a7331a4d1ba7712603dd058522613506d2dfe0",
|
||||||
"reference": "80e907bc64fbb7ce87346e97c14534d7dad5d559",
|
"reference": "54a7331a4d1ba7712603dd058522613506d2dfe0",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -3779,7 +3779,7 @@
|
|||||||
"spatie"
|
"spatie"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/spatie/image/tree/3.8.1"
|
"source": "https://github.com/spatie/image/tree/3.8.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -3791,7 +3791,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-03-27T13:01:00+00:00"
|
"time": "2025-04-25T08:04:51+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/image-optimizer",
|
"name": "spatie/image-optimizer",
|
||||||
@@ -7396,16 +7396,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/sail",
|
"name": "laravel/sail",
|
||||||
"version": "v1.41.0",
|
"version": "v1.41.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/laravel/sail.git",
|
"url": "https://github.com/laravel/sail.git",
|
||||||
"reference": "fe1a4ada0abb5e4bd99eb4e4b0d87906c00cdeec"
|
"reference": "e5692510f1ef8e0f5096cde2b885d558f8d86592"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/laravel/sail/zipball/fe1a4ada0abb5e4bd99eb4e4b0d87906c00cdeec",
|
"url": "https://api.github.com/repos/laravel/sail/zipball/e5692510f1ef8e0f5096cde2b885d558f8d86592",
|
||||||
"reference": "fe1a4ada0abb5e4bd99eb4e4b0d87906c00cdeec",
|
"reference": "e5692510f1ef8e0f5096cde2b885d558f8d86592",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -7455,7 +7455,7 @@
|
|||||||
"issues": "https://github.com/laravel/sail/issues",
|
"issues": "https://github.com/laravel/sail/issues",
|
||||||
"source": "https://github.com/laravel/sail"
|
"source": "https://github.com/laravel/sail"
|
||||||
},
|
},
|
||||||
"time": "2025-01-24T15:45:36+00:00"
|
"time": "2025-04-22T13:39:39+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mockery/mockery",
|
"name": "mockery/mockery",
|
||||||
@@ -7953,27 +7953,27 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pestphp/pest-plugin-laravel",
|
"name": "pestphp/pest-plugin-laravel",
|
||||||
"version": "v3.1.0",
|
"version": "v3.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pestphp/pest-plugin-laravel.git",
|
"url": "https://github.com/pestphp/pest-plugin-laravel.git",
|
||||||
"reference": "1c4e994476375c72aa7aebaaa97aa98f5d5378cd"
|
"reference": "6801be82fd92b96e82dd72e563e5674b1ce365fc"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/1c4e994476375c72aa7aebaaa97aa98f5d5378cd",
|
"url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/6801be82fd92b96e82dd72e563e5674b1ce365fc",
|
||||||
"reference": "1c4e994476375c72aa7aebaaa97aa98f5d5378cd",
|
"reference": "6801be82fd92b96e82dd72e563e5674b1ce365fc",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"laravel/framework": "^11.39.1|^12.0.0",
|
"laravel/framework": "^11.39.1|^12.9.2",
|
||||||
"pestphp/pest": "^3.7.4",
|
"pestphp/pest": "^3.8.2",
|
||||||
"php": "^8.2.0"
|
"php": "^8.2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"laravel/dusk": "^8.2.13|dev-develop",
|
"laravel/dusk": "^8.2.13|dev-develop",
|
||||||
"orchestra/testbench": "^9.9.0|^10.0.0",
|
"orchestra/testbench": "^9.9.0|^10.2.1",
|
||||||
"pestphp/pest-dev-tools": "^3.3.0"
|
"pestphp/pest-dev-tools": "^3.4.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
@@ -8011,7 +8011,7 @@
|
|||||||
"unit"
|
"unit"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/pestphp/pest-plugin-laravel/tree/v3.1.0"
|
"source": "https://github.com/pestphp/pest-plugin-laravel/tree/v3.2.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -8023,7 +8023,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-01-24T13:22:39+00:00"
|
"time": "2025-04-21T07:40:53+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pestphp/pest-plugin-mutate",
|
"name": "pestphp/pest-plugin-mutate",
|
||||||
@@ -9913,23 +9913,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ta-tikoma/phpunit-architecture-test",
|
"name": "ta-tikoma/phpunit-architecture-test",
|
||||||
"version": "0.8.4",
|
"version": "0.8.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/ta-tikoma/phpunit-architecture-test.git",
|
"url": "https://github.com/ta-tikoma/phpunit-architecture-test.git",
|
||||||
"reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636"
|
"reference": "cf6fb197b676ba716837c886baca842e4db29005"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/89f0dea1cb0f0d5744d3ec1764a286af5e006636",
|
"url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/cf6fb197b676ba716837c886baca842e4db29005",
|
||||||
"reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636",
|
"reference": "cf6fb197b676ba716837c886baca842e4db29005",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"nikic/php-parser": "^4.18.0 || ^5.0.0",
|
"nikic/php-parser": "^4.18.0 || ^5.0.0",
|
||||||
"php": "^8.1.0",
|
"php": "^8.1.0",
|
||||||
"phpdocumentor/reflection-docblock": "^5.3.0",
|
"phpdocumentor/reflection-docblock": "^5.3.0",
|
||||||
"phpunit/phpunit": "^10.5.5 || ^11.0.0",
|
"phpunit/phpunit": "^10.5.5 || ^11.0.0 || ^12.0.0",
|
||||||
"symfony/finder": "^6.4.0 || ^7.0.0"
|
"symfony/finder": "^6.4.0 || ^7.0.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@@ -9966,9 +9966,9 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues",
|
"issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues",
|
||||||
"source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.4"
|
"source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.5"
|
||||||
},
|
},
|
||||||
"time": "2024-01-05T14:10:56+00:00"
|
"time": "2025-04-20T20:23:40+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "theseer/tokenizer",
|
"name": "theseer/tokenizer",
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('groups', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name')->unique();
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('group_user', function (Blueprint $table) {
|
||||||
|
$table->foreignId('group_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->primary(['group_id', 'user_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('group_has_permissions', function (Blueprint $table) {
|
||||||
|
$table->foreignId('group_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('permission_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->primary(['group_id', 'permission_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('groups');
|
||||||
|
Schema::dropIfExists('group_user');
|
||||||
|
Schema::dropIfExists('group_has_permissions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,11 +11,8 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::create('category_project', function (Blueprint $table) {
|
Schema::table('users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->softDeletes();
|
||||||
$table->foreignId('project_id')->constrained();
|
|
||||||
$table->foreignId('category_id')->constrained();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +21,9 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('category_project');
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -14,12 +14,34 @@ class PermissionSeeder extends Seeder
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$permissions = [
|
$permissions = [
|
||||||
|
// Permissions for Projects
|
||||||
|
'create projects',
|
||||||
|
'edit projects',
|
||||||
|
'delete projects',
|
||||||
|
'view projects',
|
||||||
|
|
||||||
|
// Permissions for Documents
|
||||||
'create projects',
|
'create projects',
|
||||||
'edit projects',
|
'edit projects',
|
||||||
'delete projects',
|
'delete projects',
|
||||||
'view projects',
|
'view projects',
|
||||||
'manage users',
|
|
||||||
'approve documents',
|
'approve documents',
|
||||||
|
|
||||||
|
'manage users',
|
||||||
|
|
||||||
|
// Permissions for roles
|
||||||
|
'view roles',
|
||||||
|
'create roles',
|
||||||
|
'edit roles',
|
||||||
|
'delete roles',
|
||||||
|
|
||||||
|
// Permissions for permissions
|
||||||
|
'view permissions',
|
||||||
|
'create permissions',
|
||||||
|
'edit permissions',
|
||||||
|
'delete permissions',
|
||||||
|
'assign permissions',
|
||||||
|
'revoke permissions',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($permissions as $permission) {
|
foreach ($permissions as $permission) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Spatie\Permission\Models\Permission;
|
use Spatie\Permission\Models\Permission;
|
||||||
@@ -15,18 +16,71 @@ class RolePermissionSeeder extends Seeder
|
|||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// database/seeders/RolePermissionSeeder.php
|
// database/seeders/RolePermissionSeeder.php
|
||||||
$admin = Role::firstOrCreate([
|
|
||||||
|
// Crear rol de administrador
|
||||||
|
$adminRole = Role::updateOrCreate(
|
||||||
|
['name' => 'admin'],
|
||||||
|
//['description' => 'Administrador del sistema']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Obtener o crear todos los permisos existentes
|
||||||
|
$permissions = Permission::all();
|
||||||
|
|
||||||
|
if ($permissions->isEmpty()) {
|
||||||
|
// Crear permisos básicos si no existen
|
||||||
|
$permissions = collect([
|
||||||
|
'view projects',
|
||||||
|
'edit projects',
|
||||||
|
'delete projects',
|
||||||
|
'view roles',
|
||||||
|
'create roles',
|
||||||
|
'edit roles',
|
||||||
|
'delete roles',
|
||||||
|
'view permissions',
|
||||||
|
'create permissions',
|
||||||
|
'edit permissions',
|
||||||
|
'delete permissions',
|
||||||
|
'assign permissions',
|
||||||
|
'revoke permissions',
|
||||||
|
|
||||||
|
])->map(function ($permission) {
|
||||||
|
return Permission::updateOrCreate(
|
||||||
|
['name' => $permission],
|
||||||
|
['guard_name' => 'web']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sincronizar todos los permisos con el rol admin
|
||||||
|
$allPermissions = Permission::all();
|
||||||
|
$adminRole->syncPermissions($allPermissions);
|
||||||
|
$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');
|
||||||
|
$user = User::where('email', $adminEmail)->first();
|
||||||
|
if ($user) {
|
||||||
|
// Asignar rol solo si no lo tiene
|
||||||
|
if (!$user->hasRole($adminRole)) {
|
||||||
|
$user->assignRole($adminRole);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Crear solo si no existe
|
||||||
|
User::create([
|
||||||
'name' => 'admin',
|
'name' => 'admin',
|
||||||
'guard_name' => 'web'
|
'email' => $adminEmail,
|
||||||
]);
|
'password' => bcrypt(env('ADMIN_PASSWORD', '12345678')),
|
||||||
|
'email_verified_at' => now()
|
||||||
$permission = Permission::firstOrCreate([
|
])->assignRole($adminRole);
|
||||||
'name' => 'create projects',
|
}
|
||||||
'guard_name' => 'web'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Asignar TODOS los permisos
|
|
||||||
$admin->givePermissionTo(Permission::all());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
package-lock.json
generated
9
package-lock.json
generated
@@ -5,6 +5,7 @@
|
|||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@heroicons/react": "^2.0.18",
|
||||||
"@tailwindcss/vite": "^4.0.7",
|
"@tailwindcss/vite": "^4.0.7",
|
||||||
"@yaireo/tagify": "^4.34.0",
|
"@yaireo/tagify": "^4.34.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
@@ -421,6 +422,14 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@heroicons/react": {
|
||||||
|
"version": "2.0.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.18.tgz",
|
||||||
|
"integrity": "sha512-7TyMjRrZZMBPa+/5Y8lN0iyvUU/01PeMGX2+RE7cQWpEUIcb4QotzUObFkJDejj/HUH4qjP/eQ0gzzKs2f+6Yw==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">= 16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.34.8",
|
"version": "4.34.8",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.8.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.8.tgz",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"dev": "vite"
|
"dev": "vite"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@heroicons/react": "^2.0.18",
|
||||||
"@tailwindcss/vite": "^4.0.7",
|
"@tailwindcss/vite": "^4.0.7",
|
||||||
"@yaireo/tagify": "^4.34.0",
|
"@yaireo/tagify": "^4.34.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
|
|||||||
@@ -64,3 +64,22 @@ select:focus[data-flux-control] {
|
|||||||
/* \[:where(&)\]:size-4 {
|
/* \[:where(&)\]:size-4 {
|
||||||
@apply size-4;
|
@apply size-4;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
/* resources/css/app.css */
|
||||||
|
@layer components {
|
||||||
|
.permission-card {
|
||||||
|
@apply transition-all duration-200 ease-in-out transform hover:scale-[1.02] hover:shadow-lg;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark .permission-card {
|
||||||
|
@apply hover:bg-gray-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-badge {
|
||||||
|
@apply px-2 py-1 rounded-full text-xs font-medium flex items-center space-x-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
@apply inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 active:bg-blue-900 focus:outline-none focus:border-blue-900 focus:ring focus:ring-blue-300 disabled:opacity-25 transition;
|
||||||
|
}
|
||||||
|
|||||||
62
resources/js/folder-dnd.js
Normal file
62
resources/js/folder-dnd.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// resources/js/folder-dnd.js
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const folders = document.querySelectorAll('.folder-item');
|
||||||
|
|
||||||
|
folders.forEach(folder => {
|
||||||
|
folder.draggable = true;
|
||||||
|
|
||||||
|
folder.addEventListener('dragstart', (e) => {
|
||||||
|
e.dataTransfer.setData('text/plain', folder.dataset.folderId);
|
||||||
|
folder.classList.add('opacity-50');
|
||||||
|
});
|
||||||
|
|
||||||
|
folder.addEventListener('dragend', () => {
|
||||||
|
folder.classList.remove('opacity-50');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const dropZones = document.querySelectorAll('[data-drop-zone]');
|
||||||
|
|
||||||
|
dropZones.forEach(zone => {
|
||||||
|
zone.addEventListener('dragover', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
zone.classList.add('bg-blue-50', 'border-blue-200');
|
||||||
|
});
|
||||||
|
|
||||||
|
zone.addEventListener('dragleave', () => {
|
||||||
|
zone.classList.remove('bg-blue-50', 'border-blue-200');
|
||||||
|
});
|
||||||
|
|
||||||
|
zone.addEventListener('drop', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const folderId = e.dataTransfer.getData('text/plain');
|
||||||
|
const newParentId = zone.dataset.folderId;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/folders/${folderId}/move`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ parent_id: newParentId })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error moving folder:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
zone.classList.remove('bg-blue-50', 'border-blue-200');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('.folder-item').forEach(item => {
|
||||||
|
item.addEventListener('click', function() {
|
||||||
|
const folderId = this.dataset.folderId;
|
||||||
|
Livewire.emit('folderSelected', folderId);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,21 +1,32 @@
|
|||||||
@props(['folder', 'level' => 0])
|
@props(['folder', 'currentFolder', 'expandedFolders', 'level' => 0])
|
||||||
|
|
||||||
<li class="pl-{{ $level * 4 }} group">
|
<li class="pl-{{ $level * 4 }}">
|
||||||
<div class="flex items-center justify-between p-2 hover:bg-gray-50 rounded-lg cursor-pointer"
|
<div class="flex items-center justify-between p-2 hover:bg-gray-50
|
||||||
wire:click="$emit('folderSelected', {{ $folder->id }})">
|
{{ $folder->id === optional($currentFolder)->id ? 'bg-blue-50' : '' }}">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center flex-1" wire:click="selectFolder({{ $folder->id }})">
|
||||||
<x-icons icon="folder" class="w-5 h-5 mr-2 text-yellow-500" />
|
<button wire:click.prevent="toggleFolder({{ $folder->id }})"
|
||||||
<span class="text-sm">{{ $folder->name }}</span>
|
class="mr-2">
|
||||||
</div>
|
@if(in_array($folder->id, $expandedFolders))
|
||||||
@if($folder->children->isNotEmpty())
|
<x-icons.chevron-down class="w-4 h-4" />
|
||||||
<x-icons icon="chevron-right" class="w-4 h-4 text-gray-400 transform group-hover:rotate-90 transition-transform" />
|
@else
|
||||||
|
<x-icons.chevron-right class="w-4 h-4" />
|
||||||
@endif
|
@endif
|
||||||
|
</button>
|
||||||
|
<x-icons.folder class="w-5 h-5 mr-2 text-yellow-500" />
|
||||||
|
<span>{{ $folder->name }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if($folder->children->isNotEmpty())
|
@if(in_array($folder->id, $expandedFolders))
|
||||||
<ul class="mt-1 space-y-1">
|
<ul class="ml-4">
|
||||||
@foreach($folder->children as $child)
|
@foreach($folder->children as $child)
|
||||||
<x-folder-item :folder="$child" :level="$level + 1" />
|
<x-folder-item
|
||||||
|
:folder="$child"
|
||||||
|
:currentFolder="$currentFolder"
|
||||||
|
:expandedFolders="$expandedFolders"
|
||||||
|
:level="$level + 1"
|
||||||
|
wire:key="folder-{{ $child->id }}"
|
||||||
|
/>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
9
resources/views/components/label.blade.php
Normal file
9
resources/views/components/label.blade.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{{-- resources/views/components/label.blade.php --}}
|
||||||
|
@props(['for' => null, 'value' => null])
|
||||||
|
|
||||||
|
<label
|
||||||
|
{{ $attributes->merge(['class' => 'block text-sm font-medium text-gray-700']) }}
|
||||||
|
for="{{ $for }}"
|
||||||
|
>
|
||||||
|
{{ $value ?? $slot }}
|
||||||
|
</label>
|
||||||
15
resources/views/components/layouts/livewire-app.blade.php
Normal file
15
resources/views/components/layouts/livewire-app.blade.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ $title ?? 'Proyecto' }}</title>
|
||||||
|
@livewireStyles
|
||||||
|
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Integra tu sidebar aquí si es necesario -->
|
||||||
|
<div class="container mx-auto p-4">
|
||||||
|
{{ $slot }}
|
||||||
|
</div>
|
||||||
|
@livewireScripts
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
<x-icons icon="document" class="w-5 h-5 mr-3" />
|
<x-icons icon="document" class="w-5 h-5 mr-3" />
|
||||||
Documentos
|
Documentos
|
||||||
</x-nav-link>
|
</x-nav-link>
|
||||||
|
@can('view roles')
|
||||||
|
<x-nav-link :href="route('roles.index')" :active="request()->routeIs('roles.*')">
|
||||||
|
{{ __('Roles') }}
|
||||||
|
</x-nav-link>
|
||||||
|
@endcan
|
||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
|||||||
69
resources/views/livewire/file-upload.blade.php
Normal file
69
resources/views/livewire/file-upload.blade.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<!-- resources/views/livewire/file-upload.blade.php -->
|
||||||
|
<div class="relative p-8 mt-4 border-2 border-dashed rounded-lg"
|
||||||
|
x-data="{ isDragging: false }"
|
||||||
|
@dragover.prevent="isDragging = true"
|
||||||
|
@dragleave.prevent="isDragging = false"
|
||||||
|
@drop.prevent="isDragging = false; $wire.uploadFiles(event.dataTransfer.files)"
|
||||||
|
:class="{ 'border-blue-500 bg-blue-50': isDragging }">
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<input type="file" id="fileInput" wire:model="files" multiple class="hidden">
|
||||||
|
|
||||||
|
<template x-if="!$wire.previews.length">
|
||||||
|
<div>
|
||||||
|
<x-icons icon="upload" class="w-12 h-12 mx-auto text-gray-400" />
|
||||||
|
<p class="mt-2 text-sm text-gray-600">
|
||||||
|
Arrastra archivos aquí o
|
||||||
|
<button class="text-blue-600 hover:underline"
|
||||||
|
@click="document.getElementById('fileInput').click()">
|
||||||
|
selecciona desde tu equipo
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
<p class="mt-1 text-xs text-gray-500">
|
||||||
|
Máximo {{ $maxSize }}MB por archivo
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template x-if="$wire.previews.length">
|
||||||
|
<div class="grid grid-cols-2 gap-4 md:grid-cols-4">
|
||||||
|
<template x-for="(preview, index) in $wire.previews" :key="index">
|
||||||
|
<div class="relative p-2 border rounded-lg">
|
||||||
|
<button class="absolute top-1 right-1 text-red-500 hover:text-red-700"
|
||||||
|
@click="$wire.removePreview(index)">
|
||||||
|
<x-icons icon="x" class="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<template x-if="preview.preview">
|
||||||
|
<img :src="preview.preview" class="object-cover h-32 mx-auto rounded">
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template x-if="!preview.preview">
|
||||||
|
<x-icons icon="document" class="w-32 h-32 mx-auto text-gray-400" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="mt-2 text-xs truncate" x-text="preview.name"></div>
|
||||||
|
<div class="text-xs text-gray-500"
|
||||||
|
x-text="formatBytes(preview.size)"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function formatBytes(bytes) {
|
||||||
|
const units = ['B', 'KB', 'MB', 'GB'];
|
||||||
|
let size = bytes;
|
||||||
|
let unitIndex = 0;
|
||||||
|
|
||||||
|
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||||
|
size /= 1024;
|
||||||
|
unitIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
21
resources/views/livewire/group-search.blade.php
Normal file
21
resources/views/livewire/group-search.blade.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{{-- resources/views/livewire/group-search.blade.php --}}
|
||||||
|
<div>
|
||||||
|
<x-input type="search"
|
||||||
|
wire:model.live="search"
|
||||||
|
placeholder="Buscar grupos..."
|
||||||
|
class="w-full" />
|
||||||
|
|
||||||
|
<div class="mt-2 space-y-2">
|
||||||
|
@foreach($groups as $group)
|
||||||
|
<div wire:click="selectGroup({{ $group->id }})"
|
||||||
|
@class([
|
||||||
|
'p-3 cursor-pointer rounded-lg transition-colors',
|
||||||
|
'bg-green-100 dark:bg-green-900' => $selectedGroup === $group->id,
|
||||||
|
'hover:bg-gray-100 dark:hover:bg-gray-700' => $selectedGroup !== $group->id
|
||||||
|
])>
|
||||||
|
<p class="text-gray-800 dark:text-gray-200">{{ $group->name }}</p>
|
||||||
|
<p class="text-sm text-gray-600 dark:text-gray-400">{{ $group->users_count }} miembros</p>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
105
resources/views/livewire/permission-manager.blade.php
Normal file
105
resources/views/livewire/permission-manager.blade.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
{{-- resources/views/livewire/permission-manager.blade.php --}}
|
||||||
|
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
||||||
|
<h2 class="text-2xl font-semibold mb-6 text-gray-800 dark:text-gray-200">Gestión de Permisos</h2>
|
||||||
|
|
||||||
|
{{-- Selector de Recurso --}}
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Proyecto
|
||||||
|
</label>
|
||||||
|
<select wire:model.live="selectedProject"
|
||||||
|
class="w-full rounded-lg border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:text-gray-300">
|
||||||
|
<option value="">Seleccionar Proyecto</option>
|
||||||
|
@foreach($projects as $project)
|
||||||
|
<option value="{{ $project->id }}">{{ $project->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||||
|
Carpeta (Opcional)
|
||||||
|
</label>
|
||||||
|
<select wire:model="selectedFolder"
|
||||||
|
class="w-full rounded-lg border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:text-gray-300"
|
||||||
|
{{ !$folders->count() ? 'disabled' : '' }}>
|
||||||
|
<option value="">Seleccionar Carpeta</option>
|
||||||
|
@foreach($folders as $folder)
|
||||||
|
<option value="{{ $folder->id }}">{{ $folder->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Selector de Usuario/Grupo --}}
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="flex items-center space-x-4 mb-4">
|
||||||
|
<button @class([
|
||||||
|
'px-4 py-2 rounded-lg font-medium',
|
||||||
|
'bg-blue-600 text-white' => $assignTo === 'user',
|
||||||
|
'bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300' => $assignTo !== 'user'
|
||||||
|
]) wire:click="setAssignTo('user')">
|
||||||
|
Usuario
|
||||||
|
</button>
|
||||||
|
<button @class([
|
||||||
|
'px-4 py-2 rounded-lg font-medium',
|
||||||
|
'bg-blue-600 text-white' => $assignTo === 'group',
|
||||||
|
'bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300' => $assignTo !== 'group'
|
||||||
|
]) wire:click="setAssignTo('group')">
|
||||||
|
Grupo
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($assignTo === 'user')
|
||||||
|
<livewire:user-search :key="'user-search-'.$selectedProject"/>
|
||||||
|
@else
|
||||||
|
<livewire:group-search :key="'group-search-'.$selectedProject"/>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Permisos --}}
|
||||||
|
<div class="space-y-4">
|
||||||
|
<h3 class="text-lg font-medium text-gray-800 dark:text-gray-200 mb-4">Permisos Disponibles</h3>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
@foreach($permissions as $permission)
|
||||||
|
<label @class([
|
||||||
|
'flex items-center p-4 border rounded-lg cursor-pointer transition-colors',
|
||||||
|
'border-blue-200 bg-blue-50 dark:bg-blue-900/20 dark:border-blue-800' => in_array($permission, $selectedPermissions),
|
||||||
|
'border-gray-200 hover:border-blue-200 dark:border-gray-700 dark:hover:border-blue-800' => !in_array($permission, $selectedPermissions)
|
||||||
|
])>
|
||||||
|
<input type="checkbox"
|
||||||
|
value="{{ $permission }}"
|
||||||
|
wire:model.live="selectedPermissions"
|
||||||
|
class="rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700">
|
||||||
|
<span class="ml-3 text-sm text-gray-700 dark:text-gray-300">
|
||||||
|
{{ __("permissions.$permission") }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Botones de Acción --}}
|
||||||
|
<div class="mt-8 flex justify-end space-x-4">
|
||||||
|
<button wire:click="savePermissions"
|
||||||
|
@class([
|
||||||
|
'px-6 py-2 rounded-lg font-medium',
|
||||||
|
'bg-blue-600 hover:bg-blue-700 text-white' => $canSave,
|
||||||
|
'bg-gray-400 cursor-not-allowed text-gray-100' => !$canSave
|
||||||
|
])
|
||||||
|
{{ !$canSave ? 'disabled' : '' }}>
|
||||||
|
Guardar Permisos
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Listado de Permisos Actuales --}}
|
||||||
|
<div class="mt-12 bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
||||||
|
<h3 class="text-lg font-medium text-gray-800 dark:text-gray-200 mb-4">Permisos Asignados</h3>
|
||||||
|
|
||||||
|
<livewire:permissions-list :resourceId="$selectedResourceId"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
56
resources/views/livewire/permissions-list.blade.php
Normal file
56
resources/views/livewire/permissions-list.blade.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{{-- resources/views/livewire/permissions-list.blade.php --}}
|
||||||
|
<div>
|
||||||
|
<div class="space-y-6">
|
||||||
|
{{-- Listado de Usuarios --}}
|
||||||
|
@foreach($users as $user)
|
||||||
|
<div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-4">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<div>
|
||||||
|
<p class="font-medium text-gray-800 dark:text-gray-200">{{ $user->name }}</p>
|
||||||
|
<p class="text-sm text-gray-600 dark:text-gray-400">{{ $user->email }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex space-x-2">
|
||||||
|
@foreach($permissions as $type => $perms)
|
||||||
|
@if($user->hasAnyPermission($perms))
|
||||||
|
<span class="px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded-full">
|
||||||
|
{{ __("permissions.$type") }}
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
<button
|
||||||
|
wire:click="revokePermission('{{ $perms->first()->id }}', 'user', '{{ $user->id }}')"
|
||||||
|
class="text-red-500 hover:text-red-700">
|
||||||
|
<x-heroicon-o-trash class="w-5 h-5"/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
{{-- Listado de Grupos --}}
|
||||||
|
@foreach($groups as $group)
|
||||||
|
<div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-4">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<div>
|
||||||
|
<p class="font-medium text-gray-800 dark:text-gray-200">{{ $group->name }}</p>
|
||||||
|
<p class="text-sm text-gray-600 dark:text-gray-400">{{ $group->description }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex space-x-2">
|
||||||
|
@foreach($permissions as $type => $perms)
|
||||||
|
@if($group->hasAnyPermission($perms))
|
||||||
|
<span class="px-2 py-1 text-xs bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 rounded-full">
|
||||||
|
{{ __("permissions.$type") }}
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
<button
|
||||||
|
wire:click="revokePermission('{{ $perms->first()->id }}', 'group', '{{ $group->id }}')"
|
||||||
|
class="text-red-500 hover:text-red-700">
|
||||||
|
<x-heroicon-o-trash class="w-5 h-5"/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,36 +1,53 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- Header del Proyecto -->
|
<!-- Header y Breadcrumbs -->
|
||||||
<div class="flex items-center justify-between pb-6 border-b">
|
<div class="p-4 bg-white border-b">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-2xl font-bold">{{ $project->name }}</h1>
|
<nav class="flex space-x-2 text-sm">
|
||||||
<div class="flex items-center mt-2 space-x-4">
|
<a wire:click="currentFolder = null" class="cursor-pointer text-gray-600 hover:text-blue-600">
|
||||||
<span class="px-2 py-1 text-sm rounded-full bg-blue-100 text-blue-800">
|
Inicio
|
||||||
{{ ucfirst($project->status) }}
|
</a>
|
||||||
</span>
|
@foreach($this->breadcrumbs as $folder)
|
||||||
<span class="text-sm text-gray-500">
|
<span class="text-gray-400">/</span>
|
||||||
{{ $project->created_at->format('d/m/Y') }}
|
<a wire:click="selectFolder({{ $folder->id }})"
|
||||||
</span>
|
class="cursor-pointer text-gray-600 hover:text-blue-600">
|
||||||
</div>
|
{{ $folder->name }}
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
</nav>
|
||||||
|
<h1 class="mt-2 text-2xl font-bold">{{ $project->name }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ route('projects.edit', $project) }}"
|
<a href="{{ route('projects.edit', $project) }}"
|
||||||
class="px-4 py-2 text-white bg-blue-600 rounded-lg hover:bg-blue-700">
|
class="px-4 py-2 text-white bg-blue-600 rounded-lg hover:bg-blue-700">
|
||||||
Editar Proyecto
|
Editar Proyecto
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Layout Principal -->
|
<!-- Barra de Herramientas y Contenido -->
|
||||||
<div class="grid grid-cols-1 gap-6 mt-6 lg:grid-cols-4">
|
<div class="grid grid-cols-1 gap-6 p-4 lg:grid-cols-4">
|
||||||
<!-- Treeview de Carpetas -->
|
<!-- Treeview de Carpetas -->
|
||||||
<div class="col-span-1 bg-white rounded-lg shadow">
|
<div class="col-span-1 bg-white rounded-lg shadow">
|
||||||
<div class="p-4 border-b">
|
<div class="p-4 border-b">
|
||||||
<h3 class="font-medium">Estructura de Carpetas</h3>
|
<div class="flex items-center justify-between">
|
||||||
|
<h3 class="font-medium">Carpetas</h3>
|
||||||
|
<button wire:click="createFolder"
|
||||||
|
class="p-1 text-gray-600 hover:bg-gray-100 rounded">
|
||||||
|
<x-icons icon="plus" class="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<input type="text"
|
||||||
|
wire:model.live="folderName"
|
||||||
|
placeholder="Nueva carpeta"
|
||||||
|
class="w-full p-2 mt-2 border rounded"
|
||||||
|
@keyup.enter="createFolder">
|
||||||
</div>
|
</div>
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<ul class="space-y-2">
|
<ul class="space-y-2">
|
||||||
@foreach($rootFolders as $folder)
|
@foreach($project->rootFolders as $folder)
|
||||||
<x-folder-item
|
<x-folder-item
|
||||||
:folder="$folder"
|
:folder="$folder"
|
||||||
:selectedFolderId="$selectedFolderId"
|
:currentFolder="$currentFolder"
|
||||||
:expandedFolders="$expandedFolders"
|
:expandedFolders="$expandedFolders"
|
||||||
wire:key="folder-{{ $folder->id }}"
|
wire:key="folder-{{ $folder->id }}"
|
||||||
/>
|
/>
|
||||||
@@ -39,11 +56,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Listado de Documentos -->
|
<!-- Documentos y Subida de Archivos -->
|
||||||
<div class="col-span-3">
|
<div class="col-span-3">
|
||||||
<div class="bg-white rounded-lg shadow">
|
<div class="bg-white rounded-lg shadow">
|
||||||
<div class="p-4 border-b">
|
<div class="p-4 border-b">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<h3 class="font-medium">Documentos</h3>
|
<h3 class="font-medium">Documentos</h3>
|
||||||
|
<input type="file"
|
||||||
|
wire:model="files"
|
||||||
|
multiple
|
||||||
|
class="hidden"
|
||||||
|
id="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">
|
||||||
|
Subir Archivos
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
@@ -51,12 +79,12 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Nombre</th>
|
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Nombre</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Versiones</th>
|
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Versiones</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Tamaño</th>
|
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Última Actualización</th>
|
||||||
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Estado</th>
|
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Estado</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="bg-white divide-y divide-gray-200">
|
<tbody class="bg-white divide-y divide-gray-200">
|
||||||
@foreach($this->documents as $document)
|
@forelse($this->documents as $document)
|
||||||
<tr class="hover:bg-gray-50">
|
<tr class="hover:bg-gray-50">
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
@@ -65,16 +93,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
{{ $document->versions->count() }}
|
{{ $document->versions_count }}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
{{ $document->human_readable_size }}
|
{{ $document->updated_at->diffForHumans() }}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap">
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
<x-status-badge :status="$document->status" />
|
<x-status-badge :status="$document->status" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
|
||||||
|
No se encontraron documentos
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
38
resources/views/livewire/toolbar.blade.php
Normal file
38
resources/views/livewire/toolbar.blade.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<!-- resources/views/livewire/toolbar.blade.php -->
|
||||||
|
@props(['project', 'currentFolder'=> null]) <!-- Definir props -->
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between space-x-4 border-t pt-4 mt-4">
|
||||||
|
<!-- Grupo izquierdo: Acciones básicas -->
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<!-- Crear nueva carpeta -->
|
||||||
|
@if($currentFolder)
|
||||||
|
<button wire:click="$emit('showCreateFolderModal', {{ $currentFolder->id }})"
|
||||||
|
class="px-3 py-2 text-sm bg-white border rounded-lg hover:bg-gray-50">
|
||||||
|
<x-icons icon="folder-add" class="w-5 h-5 mr-1 text-blue-600" />
|
||||||
|
Nueva Carpeta
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Input de archivo con folder actual -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Subir archivos -->
|
||||||
|
<input type="file" id="file-input" wire:model="files" data-folder-id="{{ $currentFolder?->id }}" multiple class="hidden">
|
||||||
|
|
||||||
|
<button wire:click="$emit('showUploadModal')"
|
||||||
|
class="px-3 py-2 text-sm bg-white border rounded-lg hover:bg-gray-50">
|
||||||
|
<x-icons icon="upload" class="w-5 h-5 mr-1 text-green-600" />
|
||||||
|
Subir Archivos
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Grupo derecho: Acciones contextuales -->
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
@if($currentFolder)
|
||||||
|
<span class="text-sm text-gray-500">
|
||||||
|
<x-icons icon="folder" class="w-4 h-4 inline mr-1 text-yellow-500" />
|
||||||
|
{{ $currentFolder->name }}
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
21
resources/views/livewire/user-search.blade.php
Normal file
21
resources/views/livewire/user-search.blade.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{{-- resources/views/livewire/user-search.blade.php --}}
|
||||||
|
<div>
|
||||||
|
<x-input type="search"
|
||||||
|
wire:model.live="search"
|
||||||
|
placeholder="Buscar usuarios..."
|
||||||
|
class="w-full" />
|
||||||
|
|
||||||
|
<div class="mt-2 space-y-2">
|
||||||
|
@foreach($users as $user)
|
||||||
|
<div wire:click="selectUser({{ $user->id }})"
|
||||||
|
@class([
|
||||||
|
'p-3 cursor-pointer rounded-lg transition-colors',
|
||||||
|
'bg-blue-100 dark:bg-blue-900' => $selectedUser === $user->id,
|
||||||
|
'hover:bg-gray-100 dark:hover:bg-gray-700' => $selectedUser !== $user->id
|
||||||
|
])>
|
||||||
|
<p class="text-gray-800 dark:text-gray-200">{{ $user->name }}</p>
|
||||||
|
<p class="text-sm text-gray-600 dark:text-gray-400">{{ $user->email }}</p>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,46 +1,74 @@
|
|||||||
<!-- 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">
|
<x-slot name="header">
|
||||||
<h2 class="text-xl font-semibold leading-tight text-gray-800">
|
<h2 class="flex items-center gap-2 text-xl font-semibold leading-tight text-gray-800">
|
||||||
Nuevo Proyecto
|
<!-- Icono (ejemplo con Heroicons) -->
|
||||||
|
<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>
|
</h2>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
|
<header class="bg-white shadow">
|
||||||
|
<div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8">
|
||||||
|
<h2 class="flex items-center text-xl font-semibold leading-tight text-gray-800">
|
||||||
|
<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="py-6">
|
||||||
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
|
<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="overflow-hidden bg-white shadow-sm sm:rounded-lg">
|
||||||
<div class="p-6 bg-white border-b border-gray-200">
|
<div class="p-6 bg-white border-b border-gray-200">
|
||||||
<form method="POST" action="{{ route('projects.store') }}" enctype="multipart/form-data">
|
<form method="POST" action="{{ route('projects.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
<!-- Sección de Información Básica -->
|
|
||||||
<div class="grid gap-6 mb-8 md:grid-cols-2">
|
<table class="w-full mb-8">
|
||||||
<!-- Columna Izquierda -->
|
<tbody>
|
||||||
<div>
|
|
||||||
<!-- Nombre -->
|
<!-- Nombre -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label for="name" value="__('Nombre del Proyecto')" />
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
<x-input id="name" class="block w-full mt-1"
|
<x-label for="name" :value="__('Nombre del Proyecto')" />
|
||||||
type="text" name="name" value="old('name')" required />
|
</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')
|
@error('name')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- NombDescripción -->
|
<!-- Descripción -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label for="description" value="__('Descripción')" />
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
<x-textarea id="description" class="block w-full mt-1"
|
<x-label for="description" :value="__('Descripción')" />
|
||||||
name="description" rows="4" required>
|
</td>
|
||||||
|
<td class="py-3">
|
||||||
|
<x-textarea id="description" class="block w-full mt-1" name="description" rows="4" required>
|
||||||
{{ old('description') }}
|
{{ old('description') }}
|
||||||
</x-textarea>
|
</x-textarea>
|
||||||
@error('description')
|
@error('description')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- Editor Enriquecido -->
|
<!-- Editor Enriquecido -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label for="description" value="__('Descripción Detallada')" />
|
<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">
|
<div id="editor-container">
|
||||||
<!-- Barra de herramientas -->
|
<!-- Barra de herramientas -->
|
||||||
<div id="toolbar">
|
<div id="toolbar">
|
||||||
@@ -52,32 +80,41 @@
|
|||||||
<button class="ql-code-block"></button>
|
<button class="ql-code-block"></button>
|
||||||
<button class="ql-link"></button>
|
<button class="ql-link"></button>
|
||||||
<button class="ql-image"></button>
|
<button class="ql-image"></button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Editor -->
|
<!-- Editor -->
|
||||||
<div id="rich-editor">{!! old('description') !!}</div>
|
<input type="hidden" name="description">
|
||||||
|
<div id="rich-editor" class="h-48">{!! old('description') !!}</div>
|
||||||
</div>
|
</div>
|
||||||
@error('description')
|
@error('description')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- Estado -->
|
<!-- Estado -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label for="status" value="__('Estado del Proyecto')" />
|
<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">
|
<x-select id="status" name="status" class="block w-full mt-1">
|
||||||
<option value="active" {{ old('status') == 'active' ? 'selected' : '' }}>Activo</option>
|
<option :value="active" {{ old('status') == 'active' ? 'selected' : '' }}>Activo</option>
|
||||||
<option value="inactive" {{ old('status') == 'inactive' ? 'selected' : '' }}>Inactivo</option>
|
<option :value="inactive" {{ old('status') == 'inactive' ? 'selected' : '' }}>Inactivo</option>
|
||||||
</x-select>
|
</x-select>
|
||||||
@error('status')
|
@error('status')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<!-- Imagen de Referencia -->
|
<!-- Imagen de Referencia -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label for="project_image" value="__('Imagen de Referencia')" />
|
<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">
|
<div class="relative mt-1">
|
||||||
<input type="file" id="project_image" name="project_image"
|
<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
|
class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4
|
||||||
@@ -94,19 +131,20 @@
|
|||||||
@error('project_image')
|
@error('project_image')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
|
|
||||||
<!-- Columna Derecha -->
|
|
||||||
<div>
|
|
||||||
<!-- Dirección -->
|
<!-- Dirección -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label value="__('Ubicación')" />
|
<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 class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||||
<div>
|
<div>
|
||||||
<x-input id="address" class="block w-full mt-1"
|
<x-input id="address" class="block w-full mt-1"
|
||||||
type="text" name="address"
|
type="text" name="address"
|
||||||
value="old('address')"
|
:value="old('address')"
|
||||||
placeholder="Dirección" />
|
placeholder="Dirección" />
|
||||||
@error('address')
|
@error('address')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@@ -116,7 +154,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<x-input id="postal_code" class="block w-full mt-1"
|
<x-input id="postal_code" class="block w-full mt-1"
|
||||||
type="text" name="postal_code"
|
type="text" name="postal_code"
|
||||||
value="old('postal_code')"
|
:value="old('postal_code')"
|
||||||
placeholder="Código Postal" />
|
placeholder="Código Postal" />
|
||||||
@error('postal_code')
|
@error('postal_code')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@@ -126,7 +164,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<x-input id="province" class="block w-full mt-1"
|
<x-input id="province" class="block w-full mt-1"
|
||||||
type="text" name="province"
|
type="text" name="province"
|
||||||
value="old('province')"
|
:value="old('province')"
|
||||||
placeholder="Provincia" />
|
placeholder="Provincia" />
|
||||||
@error('province')
|
@error('province')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@@ -135,9 +173,9 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<x-select id="country" name="country" class="block w-full mt-1">
|
<x-select id="country" name="country" class="block w-full mt-1">
|
||||||
<option value="">Seleccione País</option>
|
<option :value="">Seleccione País</option>
|
||||||
@foreach(config('countries') as $code => $name)
|
@foreach(config('countries') as $code => $name)
|
||||||
<option value="{{ $code }}" {{ old('country') == $code ? 'selected' : '' }}>
|
<option :value="{{ $code }}" {{ old('country') == $code ? 'selected' : '' }}>
|
||||||
{{ $name }}
|
{{ $name }}
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -147,24 +185,28 @@
|
|||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- Mapa para Coordenadas -->
|
<!-- Mapa para Coordenadas -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label value="__('Seleccione Ubicación en el Mapa')" />
|
<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 id="map" class="h-64 rounded-lg border-2 border-gray-200"></div>
|
||||||
<div class="grid grid-cols-2 gap-4 mt-2">
|
<div class="grid grid-cols-2 gap-4 mt-2">
|
||||||
<div>
|
<div>
|
||||||
<x-label for="latitude" value="__('Latitud')" />
|
<x-label for="latitude" :value="__('Latitud')" />
|
||||||
<x-input id="latitude" name="latitude"
|
<x-input id="latitude" name="latitude"
|
||||||
type="number" step="any"
|
type="number" step="any"
|
||||||
value="old('latitude')" required />
|
:value="old('latitude')" required />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<x-label for="longitude" value="__('Longitud')" />
|
<x-label for="longitude" :value="__('Longitud')" />
|
||||||
<x-input id="longitude" name="longitude"
|
<x-input id="longitude" name="longitude"
|
||||||
type="number" step="any"
|
type="number" step="any"
|
||||||
value="old('longitude')" required />
|
:value="old('longitude')" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@error('latitude')
|
@error('latitude')
|
||||||
@@ -173,26 +215,24 @@
|
|||||||
@error('longitude')
|
@error('longitude')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
</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 -->
|
<!-- Icono y Categorías -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label value="__('Identificación Visual')" />
|
<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 class="grid grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<x-label for="icon" value="__('Icono del Proyecto')" />
|
<x-label for="icon" :value="__('Icono del Proyecto')" />
|
||||||
<div class="relative mt-1">
|
<div class="relative mt-1">
|
||||||
<select id="icon" name="icon"
|
<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">
|
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>
|
<option :value="">Seleccionar Icono</option>
|
||||||
@foreach(config('project.icons') as $icon)
|
@foreach(config('project.icons') as $icon)
|
||||||
<option value="{{ $icon }}"
|
<option :value="{{ $icon }}"
|
||||||
{{ old('icon') == $icon ? 'selected' : '' }}>
|
{{ old('icon') == $icon ? 'selected' : '' }}>
|
||||||
<i class="fas fa-{{ $icon }} mr-2"></i>
|
<i class="fas fa-{{ $icon }} mr-2"></i>
|
||||||
{{ Str::title($icon) }}
|
{{ Str::title($icon) }}
|
||||||
@@ -203,7 +243,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<x-label for="categories" value="__('Categorías')" />
|
<x-label for="categories" :value="__('Categorías')" />
|
||||||
<x-multiselect
|
<x-multiselect
|
||||||
name="categories[]"
|
name="categories[]"
|
||||||
:options="$categories"
|
:options="$categories"
|
||||||
@@ -212,29 +252,30 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- Fechas Importantes -->
|
<!-- Fechas Importantes -->
|
||||||
<div class="grid grid-cols-2 gap-4 mb-6">
|
<tr>
|
||||||
<div>
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
<x-label for="start_date" value="__('Fecha de Inicio')" />
|
<x-label for="start_date" :value="__('Fechas')" />
|
||||||
<x-input id="start_date" type="date"
|
</td>
|
||||||
name="start_date" value="old('start_date')" />
|
<td class="py-3">
|
||||||
</div>
|
<div class="flex items-center gap-4 mt-2">
|
||||||
<div>
|
<span class="text-gray-700">de</span>
|
||||||
<x-label for="deadline" value="__('Fecha Límite')" />
|
<x-input id="start_date" type="date" name="start_date" :value="old('start_date')" />
|
||||||
<x-input id="deadline" type="date"
|
<span class="text-gray-700">a</span>
|
||||||
name="deadline" value="old('deadline')"
|
<x-input id="deadline" type="date" name="deadline" :value="old('deadline')" min="{{ now()->format('Y-m-d') }}" />
|
||||||
min="{{ now()->format('Y-m-d') }}" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<!-- Columna Derecha -->
|
|
||||||
<div>
|
|
||||||
<!-- Archivos Adjuntos -->
|
<!-- Archivos Adjuntos -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
<x-label value="__('Documentos Iniciales')" />
|
<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 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="flex items-center justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@@ -267,20 +308,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
<!-- 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 -->
|
<!-- Miembros del Equipo -->
|
||||||
<div class="mb-6">
|
<tr>
|
||||||
Miembros del Equipo
|
<td class="w-1/4 py-3 pr-4 align-top">
|
||||||
<x-label value="__('Miembros del Equipo')" />
|
<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">
|
<div class="grid grid-cols-1 mt-2 gap-y-2 gap-x-4 sm:grid-cols-2">
|
||||||
@foreach($users as $user)
|
@foreach($users as $user)
|
||||||
<label class="flex items-center space-x-2">
|
<label class="flex items-center space-x-2">
|
||||||
@@ -296,7 +332,10 @@
|
|||||||
@error('team')
|
@error('team')
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<!-- Botones de Acción -->
|
<!-- Botones de Acción -->
|
||||||
<div class="flex justify-end mt-8 space-x-4">
|
<div class="flex justify-end mt-8 space-x-4">
|
||||||
@@ -318,19 +357,31 @@
|
|||||||
@push('styles')
|
@push('styles')
|
||||||
<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" />
|
||||||
|
|
||||||
|
<!-- Leaflet CSS -->
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
|
||||||
|
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
||||||
|
crossorigin=""/>
|
||||||
|
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@push('scripts')
|
@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 -->
|
||||||
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
||||||
|
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
||||||
|
crossorigin=""></script>
|
||||||
<script>
|
<script>
|
||||||
// Editor Quill
|
// Editor Quill
|
||||||
onst toolbarOptions = [
|
const toolbarOptions = [
|
||||||
['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
||||||
['blockquote', 'code-block'],
|
['blockquote', 'code-block'],
|
||||||
['link', 'image', 'video', 'formula'],
|
['link', 'image', 'video', 'formula'],
|
||||||
|
|
||||||
[{ 'header': 1 }, { 'header': 2 }], // custom button values
|
[{ 'header': 1 }, { 'header': 2 }], // custom button :values
|
||||||
[{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
|
[{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
|
||||||
[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
|
[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
|
||||||
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
|
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
|
||||||
@@ -382,5 +433,41 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let map;
|
||||||
|
let marker;
|
||||||
|
|
||||||
|
function initMap() {
|
||||||
|
// Coordenadas iniciales (usar valores por defecto o geolocalización)
|
||||||
|
const defaultLat = {{ old('latitude', 40.4168) }};
|
||||||
|
const defaultLng = {{ old('longitude', -3.7038) }};
|
||||||
|
|
||||||
|
map = L.map('map').setView([defaultLat, defaultLng], 13);
|
||||||
|
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
// Marcador inicial si hay valores
|
||||||
|
if(defaultLat && defaultLng) {
|
||||||
|
marker = L.marker([defaultLat, defaultLng]).addTo(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manejar clic en el mapa
|
||||||
|
map.on('click', function(e) {
|
||||||
|
if(marker) map.removeLayer(marker);
|
||||||
|
marker = L.marker(e.latlng).addTo(map);
|
||||||
|
document.getElementById('latitude').:value = e.latlng.lat.toFixed(6);
|
||||||
|
document.getElementById('longitude').:value = e.latlng.lng.toFixed(6);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializar después de cargar Leaflet
|
||||||
|
window.onload = function() {
|
||||||
|
initMap();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
@endpush
|
@endpush
|
||||||
</x-layouts.app>
|
</x-layouts.app>
|
||||||
386
resources/views/projects/create.blade.php.back
Normal file
386
resources/views/projects/create.blade.php.back
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
<!-- 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>
|
||||||
43
resources/views/roles/create.blade.php
Normal file
43
resources/views/roles/create.blade.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{{-- resources/views/roles/create.blade.php --}}
|
||||||
|
<x-layouts.app :title="__('Create Roles')">
|
||||||
|
<div class="container mx-auto px-4 py-8">
|
||||||
|
<div class="bg-white rounded-lg shadow-md p-6">
|
||||||
|
<h1 class="text-2xl font-semibold mb-6">Crear Nuevo Rol</h1>
|
||||||
|
|
||||||
|
<form action="{{ route('roles.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-gray-700 text-sm font-bold mb-2">Nombre</label>
|
||||||
|
<input type="text" name="name"
|
||||||
|
class="form-input w-full @error('name') border-red-500 @enderror"
|
||||||
|
required>
|
||||||
|
@error('name')
|
||||||
|
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-gray-700 text-sm font-bold mb-2">Permisos</label>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
|
@foreach($permissions as $permission)
|
||||||
|
<label class="flex items-center space-x-2">
|
||||||
|
<input type="checkbox" name="permissions[]"
|
||||||
|
value="{{ $permission->name }}"
|
||||||
|
class="form-checkbox">
|
||||||
|
<span class="text-sm text-gray-700">{{ $permission->name }}</span>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<button type="submit" class="btn-primary">
|
||||||
|
Crear Rol
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-layouts.app>
|
||||||
|
|
||||||
82
resources/views/roles/index.blade.php
Normal file
82
resources/views/roles/index.blade.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
<x-layouts.app :title="__('Roles')">
|
||||||
|
<div class="container mx-auto px-4 py-8">
|
||||||
|
<div class="bg-white rounded-lg shadow-md p-6">
|
||||||
|
<div class="flex justify-between items-center mb-6">
|
||||||
|
<h1 class="text-2xl font-semibold text-gray-800">Gestión de Roles</h1>
|
||||||
|
@can('create roles')
|
||||||
|
<a href="{{ route('roles.create') }}" class="btn-primary">
|
||||||
|
|
||||||
|
Nuevo Rol
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
|
<thead class="bg-gray-50">
|
||||||
|
<tr>
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nombre</th>
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Permisos</th>
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Usuarios</th>
|
||||||
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Acciones</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="bg-white divide-y divide-gray-200">
|
||||||
|
@forelse($roles as $role)
|
||||||
|
<tr>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<div class="text-sm font-medium text-gray-900">{{ $role->name }}</div>
|
||||||
|
<div class="text-sm text-gray-500">{{ $role->description }}</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
@foreach($role->permissions->take(3) as $permission)
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">
|
||||||
|
{{ $permission->name }}
|
||||||
|
</span>
|
||||||
|
@endforeach
|
||||||
|
@if($role->permissions->count() > 3)
|
||||||
|
<span class="text-xs text-gray-500">+{{ $role->permissions->count() - 3 }} más</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
|
{{ $role->users_count }} usuarios
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||||
|
@can('edit roles')
|
||||||
|
<a href="{{ route('roles.edit', $role) }}" class="text-indigo-600 hover:text-indigo-900 mr-4">
|
||||||
|
Editar
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('delete roles')
|
||||||
|
<form action="{{ route('roles.destroy', $role) }}" method="POST" class="inline">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="text-red-600 hover:text-red-900"
|
||||||
|
onclick="return confirm('¿Estás seguro de eliminar este rol?')">
|
||||||
|
Eliminar
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endcan
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
|
||||||
|
No hay roles registrados
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($roles->hasPages())
|
||||||
|
<div class="mt-6">
|
||||||
|
{{ $roles->links() }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-layouts.app>
|
||||||
21
resources/views/user-search.blade.php
Normal file
21
resources/views/user-search.blade.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{{-- resources/views/livewire/user-search.blade.php --}}
|
||||||
|
<div>
|
||||||
|
<x-input type="search"
|
||||||
|
wire:model.live="search"
|
||||||
|
placeholder="Buscar usuarios..."
|
||||||
|
class="w-full" />
|
||||||
|
|
||||||
|
<div class="mt-2 space-y-2">
|
||||||
|
@foreach($users as $user)
|
||||||
|
<div wire:click="selectUser({{ $user->id }})"
|
||||||
|
@class([
|
||||||
|
'p-3 cursor-pointer rounded-lg transition-colors',
|
||||||
|
'bg-blue-100 dark:bg-blue-900' => $selectedUser === $user->id,
|
||||||
|
'hover:bg-gray-100 dark:hover:bg-gray-700' => $selectedUser !== $user->id
|
||||||
|
])>
|
||||||
|
<p class="text-gray-800 dark:text-gray-200">{{ $user->name }}</p>
|
||||||
|
<p class="text-sm text-gray-600 dark:text-gray-400">{{ $user->email }}</p>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -41,23 +41,31 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
|||||||
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
|
||||||
Route::resource('documents', DocumentController::class);
|
Route::resource('documents', DocumentController::class);
|
||||||
Route::post('/documents/{document}/approve', [DocumentController::class, 'approve'])->name('documents.approve');
|
Route::post('/documents/{document}/approve', [DocumentController::class, 'approve'])->name('documents.approve');
|
||||||
Route::post('/documents/{document}/comment', [DocumentController::class, 'addComment'])->name('documents.comment');
|
Route::post('/documents/{document}/comment', [DocumentController::class, 'addComment'])->name('documents.comment');
|
||||||
|
|
||||||
// Carpetas
|
// Carpetas
|
||||||
Route::resource('folders', FolderController::class);
|
Route::prefix('folders')->group(function () {
|
||||||
Route::post('/folders/{folder}/documents', [FolderController::class, 'storeDocument'])->name('folders.documents.store');
|
Route::put('/{folder}/move', [FolderController::class, 'move']);
|
||||||
|
Route::post('/', [FolderController::class, 'store']);
|
||||||
|
Route::put('/{folder}', [FolderController::class, 'update']);
|
||||||
|
Route::delete('/{folder}', [FolderController::class, 'destroy']);
|
||||||
|
});
|
||||||
|
|
||||||
// Gestión de Usuarios
|
// Gestión de Usuarios
|
||||||
Route::resource('users', UserController::class)->except('show');
|
Route::resource('users', UserController::class)->except('show');
|
||||||
Route::put('/users/{user}/password', [UserController::class, 'updatePassword'])->name('users.password.update');
|
Route::put('/users/{user}/password', [UserController::class, 'updatePassword'])->name('users.password.update');
|
||||||
|
|
||||||
// Permisos y Roles
|
// Permisos y Roles
|
||||||
Route::resource('roles', RoleController::class)->except('show');
|
// Rutas para gestión de roles
|
||||||
Route::resource('permissions', PermissionController::class)->only(['index', 'store', 'update']);
|
Route::prefix('roles')->middleware(['auth', 'can:view roles'])->group(function () {
|
||||||
Route::post('/roles/{role}/permissions', [RoleController::class, 'syncPermissions'])->name('roles.permissions.sync');
|
Route::get('/', [RoleController::class, 'index']);
|
||||||
|
Route::post('/', [RoleController::class, 'store'])->middleware('can:create roles');
|
||||||
|
Route::resource('roles', \App\Http\Controllers\RoleController::class)->except(['show'])->middleware(['auth', 'verified']);
|
||||||
|
});
|
||||||
|
|
||||||
// Perfil de usuario
|
// Perfil de usuario
|
||||||
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
||||||
|
|||||||
Reference in New Issue
Block a user