feat(features): edición de elementos + catálogo de tipos de elemento

- Migración: tabla feature_types + columnas feature_type_id (FK) e is_active en features.
  Modelo FeatureType; Feature gana featureType() + casts is_active.
- Catálogo de tipos (FeatureTypeManager, ruta /feature-types): CRUD con modal
  (nombre, descripción, color), contador de usos; gateado por edit layers.
- Editor de elementos del proyecto (FeatureManager, ruta projects.features):
  tabla Rappasoft ProjectFeaturesTable (filtros nombre/capa/tipo en cabecera),
  toggle activo/inactivo y borrado individual; modal para editar nombre/tipo/activo.
- Acceso: botón "Elementos" en el dashboard del proyecto (edit layers) y enlace a
  "Tipos de elemento" desde el editor.

Tests: FeatureManagementTest (6). Suite 87 passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-25 16:12:47 +02:00
co-authored by Claude Opus 4.8
parent 1decb19bba
commit 3ee70cf48d
11 changed files with 640 additions and 2 deletions
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Livewire\Projects;
use App\Models\Feature;
use App\Models\FeatureType;
use App\Models\Project;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Layout;
use Livewire\Attributes\On;
use Livewire\Component;
#[Layout('layouts.app')]
class FeatureManager extends Component
{
public Project $project;
public $featureTypes = [];
// Edit modal
public bool $showForm = false;
public $editingId = null;
public string $name = '';
public $featureTypeId = '';
public bool $isActive = true;
public function mount(Project $project)
{
$this->project = $project;
abort_unless($this->canManage(), 403);
$this->featureTypes = FeatureType::orderBy('name')->get();
}
private function canManage(): bool
{
$user = Auth::user();
return $user->can('manage all')
|| ($user->can('edit layers') && $this->project->users()->where('user_id', $user->id)->exists());
}
#[On('feature-edit')]
public function editFeature($id): void
{
abort_unless($this->canManage(), 403);
$feature = $this->findFeature($id);
$this->editingId = $feature->id;
$this->name = $feature->name ?? '';
$this->featureTypeId = $feature->feature_type_id ?? '';
$this->isActive = (bool) $feature->is_active;
$this->resetErrorBag();
$this->showForm = true;
}
public function save(): void
{
abort_unless($this->canManage(), 403);
$this->validate([
'name' => 'required|string|max:255',
'featureTypeId' => 'nullable|exists:feature_types,id',
]);
$this->findFeature($this->editingId)->update([
'name' => $this->name,
'feature_type_id' => $this->featureTypeId ?: null,
'is_active' => $this->isActive,
]);
$this->showForm = false;
$this->dispatch('features-changed');
$this->dispatch('notify', 'Elemento actualizado');
}
private function findFeature($id): Feature
{
return Feature::whereHas('layer.phase', fn ($q) => $q->where('project_id', $this->project->id))->findOrFail($id);
}
public function render()
{
return view('livewire.projects.feature-manager');
}
}
@@ -0,0 +1,87 @@
<?php
namespace App\Livewire\Projects;
use App\Models\FeatureType;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Layout;
use Livewire\Component;
#[Layout('layouts.app')]
class FeatureTypeManager extends Component
{
public $types = [];
public bool $showForm = false;
public $editingId = null;
public string $name = '';
public string $description = '';
public string $color = '#6b7280';
public function mount()
{
abort_unless(Auth::user()->can('edit layers'), 403);
$this->loadTypes();
}
public function loadTypes(): void
{
$this->types = FeatureType::withCount('features')->orderBy('name')->get();
}
protected function rules(): array
{
return [
'name' => 'required|string|max:255|unique:feature_types,name,' . ($this->editingId ?? 'NULL'),
'description' => 'nullable|string|max:255',
'color' => 'required|string|max:7',
];
}
public function newType(): void
{
$this->reset(['editingId', 'name', 'description']);
$this->color = '#6b7280';
$this->resetErrorBag();
$this->showForm = true;
}
public function edit($id): void
{
$t = FeatureType::findOrFail($id);
$this->editingId = $t->id;
$this->name = $t->name;
$this->description = $t->description ?? '';
$this->color = $t->color ?? '#6b7280';
$this->resetErrorBag();
$this->showForm = true;
}
public function save(): void
{
abort_unless(Auth::user()->can('edit layers'), 403);
$this->validate();
FeatureType::updateOrCreate(
['id' => $this->editingId],
['name' => $this->name, 'description' => $this->description ?: null, 'color' => $this->color],
);
$this->showForm = false;
$this->loadTypes();
$this->dispatch('notify', 'Tipo de elemento guardado');
}
public function delete($id): void
{
abort_unless(Auth::user()->can('edit layers'), 403);
FeatureType::findOrFail($id)->delete();
$this->loadTypes();
$this->dispatch('notify', 'Tipo de elemento eliminado');
}
public function render()
{
return view('livewire.projects.feature-type-manager');
}
}
@@ -0,0 +1,141 @@
<?php
namespace App\Livewire\Projects;
use App\Models\Feature;
use App\Models\FeatureType;
use App\Models\Project;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\On;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
class ProjectFeaturesTable extends DataTableComponent
{
protected $model = Feature::class;
public int $projectId;
public function configure(): void
{
$this->setPrimaryKey('id')
->setDefaultSort('name', 'asc')
->setSortingPillsEnabled(false)
->setSecondaryHeaderEnabled()
->setAdditionalSelects(['features.id as id', 'features.layer_id as layer_id', 'features.feature_type_id as feature_type_id']);
}
#[On('features-changed')]
public function refreshRows(): void
{
//
}
private function canManage(): bool
{
$user = Auth::user();
return $user->can('manage all') ||
($user->can('edit layers') &&
Project::whereKey($this->projectId)->whereHas('users', fn ($q) => $q->where('user_id', $user->id))->exists());
}
public function builder(): Builder
{
abort_unless($this->canManage(), 403);
return Feature::query()
->whereHas('layer.phase', fn ($q) => $q->where('project_id', $this->projectId))
->with(['layer.phase', 'featureType']);
}
public function columns(): array
{
return [
Column::make('Elemento', 'name')
->sortable()->searchable()
->secondaryHeaderFilter('name')
->format(fn ($value) => '<span class="font-medium">' . e($value) . '</span>')
->html(),
Column::make('Capa')
->secondaryHeaderFilter('layer')
->label(fn ($row) => e($row->layer?->name ?? '—')),
Column::make('Fase')
->label(fn ($row) => e($row->layer?->phase?->name ?? '—')),
Column::make('Tipo')
->secondaryHeaderFilter('type')
->label(fn ($row) => $row->featureType
? '<span class="badge badge-sm" style="background-color:' . e($row->featureType->color) . ';color:#fff;border:0;">' . e($row->featureType->name) . '</span>'
: '<span class="text-base-content/30 text-xs">—</span>')
->html(),
Column::make('Activo', 'is_active')
->sortable()
->label(function ($row) {
if ($row->is_active) {
return '<button wire:click="toggleActive(' . $row->id . ')" class="badge badge-success badge-sm" title="Desactivar">Activo</button>';
}
return '<button wire:click="toggleActive(' . $row->id . ')" class="badge badge-ghost badge-sm" title="Activar">Inactivo</button>';
})
->html(),
Column::make('Acciones')
->label(fn ($row) =>
'<div class="flex justify-end gap-1">
<button wire:click="$dispatch(\'feature-edit\', { id: ' . $row->id . ' })" class="btn btn-xs btn-ghost" title="Editar">
<svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
</button>
<button wire:click="deleteFeature(' . $row->id . ')" wire:confirm="¿Eliminar el elemento \'' . e($row->name) . '\'? Esta acción no se puede deshacer."
class="btn btn-xs btn-error btn-outline" title="Eliminar">
<svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
</button>
</div>')
->html(),
];
}
public function filters(): array
{
$types = FeatureType::orderBy('name')->pluck('name', 'id')->toArray();
return [
TextFilter::make('Elemento', 'name')
->filter(fn (Builder $q, string $v) => $q->where('features.name', 'like', '%' . $v . '%')),
SelectFilter::make('Capa', 'layer')
->options(['' => 'Todas'] + \App\Models\Layer::whereHas('phase', fn ($q) => $q->where('project_id', $this->projectId))->orderBy('name')->pluck('name', 'id')->toArray())
->filter(fn (Builder $q, string $v) => $q->where('features.layer_id', $v)),
SelectFilter::make('Tipo', 'type')
->options(['' => 'Todos'] + $types)
->filter(fn (Builder $q, string $v) => $q->where('features.feature_type_id', $v)),
];
}
public function toggleActive(int $id): void
{
abort_unless($this->canManage(), 403);
$feature = $this->findFeature($id);
$feature->update(['is_active' => ! $feature->is_active]);
$this->dispatch('features-changed');
$this->dispatch('notify', $feature->is_active ? 'Elemento activado' : 'Elemento desactivado');
}
public function deleteFeature(int $id): void
{
abort_unless($this->canManage(), 403);
$this->findFeature($id)->delete();
$this->dispatch('features-changed');
$this->dispatch('notify', 'Elemento eliminado');
}
private function findFeature(int $id): Feature
{
return Feature::whereHas('layer.phase', fn ($q) => $q->where('project_id', $this->projectId))->findOrFail($id);
}
}
+8 -2
View File
@@ -13,16 +13,22 @@ class Feature extends Model
const STATUSES = ['planned', 'started', 'in_progress', 'completed', 'verified'];
protected $fillable = [
'layer_id', 'name', 'geometry', 'properties', 'template_id',
'progress', 'status', 'responsible', 'responsible_user_id',
'layer_id', 'name', 'geometry', 'properties', 'template_id', 'feature_type_id',
'progress', 'status', 'is_active', 'responsible', 'responsible_user_id',
'uuid', 'client_updated_at',
];
protected $casts = [
'geometry' => 'array',
'properties' => 'array',
'is_active' => 'boolean',
];
public function featureType()
{
return $this->belongsTo(FeatureType::class);
}
public function layer()
{
return $this->belongsTo(Layer::class);
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class FeatureType extends Model
{
use SoftDeletes;
protected $fillable = ['name', 'description', 'color'];
public function features()
{
return $this->hasMany(Feature::class);
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('feature_types', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('description')->nullable();
$table->string('color', 7)->default('#6b7280');
$table->timestamps();
$table->softDeletes();
});
Schema::table('features', function (Blueprint $table) {
$table->foreignId('feature_type_id')->nullable()->after('template_id')
->constrained('feature_types')->nullOnDelete();
$table->boolean('is_active')->default(true)->after('status');
});
}
public function down(): void
{
Schema::table('features', function (Blueprint $table) {
$table->dropConstrainedForeignId('feature_type_id');
$table->dropColumn('is_active');
});
Schema::dropIfExists('feature_types');
}
};
@@ -0,0 +1,61 @@
<div class="max-w-5xl mx-auto">
<a href="{{ route('projects.dashboard', $project) }}" wire:navigate class="btn btn-ghost btn-sm gap-1 mb-3">
<x-heroicon-o-arrow-left class="w-4 h-4" /> Volver
</a>
<div class="flex flex-wrap items-center justify-between gap-3 mb-5">
<div>
<h1 class="text-xl font-bold">Elementos del proyecto</h1>
<p class="text-sm text-base-content/60">{{ $project->name }} · editar nombre, tipo, activar/desactivar o eliminar</p>
</div>
<a href="{{ route('feature-types') }}" wire:navigate class="btn btn-outline btn-sm gap-1">
<x-heroicon-o-tag class="w-4 h-4" /> Tipos de elemento
</a>
</div>
<livewire:projects.project-features-table :project-id="$project->id" :key="'pft-'.$project->id" />
{{-- Modal editar elemento --}}
@if($showForm)
<div class="fixed inset-0 z-40 bg-black/50" wire:click="$set('showForm', false)"></div>
<div class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div class="bg-base-100 rounded-box shadow-2xl w-full max-w-md">
<div class="flex items-center justify-between p-4 border-b border-base-300">
<h3 class="font-bold">Editar elemento</h3>
<button wire:click="$set('showForm', false)" class="btn btn-sm btn-ghost btn-circle"><x-heroicon-o-x-mark class="w-4 h-4" /></button>
</div>
<form wire:submit.prevent="save" class="p-4 space-y-3">
<div class="form-control">
<label class="label"><span class="label-text font-medium">Nombre <span class="text-error">*</span></span></label>
<input type="text" wire:model="name" autofocus class="input input-bordered w-full @error('name') input-error @enderror" />
@error('name')<span class="text-xs text-error">{{ $message }}</span>@enderror
</div>
<div class="form-control">
<label class="label"><span class="label-text font-medium">Tipo de elemento</span></label>
<select wire:model="featureTypeId" class="select select-bordered w-full">
<option value="">Sin tipo</option>
@foreach($featureTypes as $ft)
<option value="{{ $ft->id }}">{{ $ft->name }}</option>
@endforeach
</select>
@if($featureTypes->isEmpty())
<span class="text-xs text-base-content/50 mt-1">No hay tipos.
<a href="{{ route('feature-types') }}" wire:navigate class="link link-primary">Crear tipos</a>
</span>
@endif
</div>
<div class="form-control">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" wire:model="isActive" class="toggle toggle-success toggle-sm" />
<span class="label-text">Activo</span>
</label>
</div>
<div class="flex justify-end gap-2 pt-2 border-t border-base-300">
<button type="button" wire:click="$set('showForm', false)" class="btn btn-ghost btn-sm">Cancelar</button>
<button type="submit" class="btn btn-primary btn-sm">Guardar</button>
</div>
</form>
</div>
</div>
@endif
</div>
@@ -0,0 +1,73 @@
<div class="max-w-3xl mx-auto">
<div class="flex flex-wrap items-center justify-between gap-3 mb-5">
<div>
<h1 class="text-xl font-bold">Tipos de elemento</h1>
<p class="text-sm text-base-content/60">Catálogo reutilizable de tipos para los elementos del mapa</p>
</div>
<button wire:click="newType" class="btn btn-primary btn-sm gap-2">
<x-heroicon-o-plus class="w-4 h-4" /> Nuevo tipo
</button>
</div>
@if($types->isEmpty())
<div class="flex flex-col items-center justify-center py-12 text-base-content/40">
<x-heroicon-o-tag class="w-14 h-14 mb-3" />
<p class="font-semibold">Sin tipos de elemento</p>
<p class="text-sm">Crea tipos (p. ej. Pilar, Viga, Muro) para clasificar los elementos.</p>
</div>
@else
<div class="space-y-2">
@foreach($types as $t)
<div wire:key="ftype-{{ $t->id }}" class="card bg-base-100 border border-base-300">
<div class="card-body p-3 flex-row items-center justify-between gap-3">
<div class="flex items-center gap-3 min-w-0">
<span class="w-5 h-5 rounded-full border border-base-300 shrink-0" style="background: {{ $t->color }}"></span>
<div class="min-w-0">
<div class="font-semibold">{{ $t->name }}</div>
@if($t->description)<div class="text-xs text-base-content/50 truncate">{{ $t->description }}</div>@endif
</div>
<span class="badge badge-ghost badge-sm shrink-0">{{ $t->features_count }} uso(s)</span>
</div>
<div class="flex items-center gap-1 shrink-0">
<button wire:click="edit({{ $t->id }})" class="btn btn-xs btn-ghost"><x-heroicon-o-pencil class="w-3.5 h-3.5" /></button>
<button wire:click="delete({{ $t->id }})" wire:confirm="¿Eliminar el tipo '{{ $t->name }}'? Los elementos que lo usen quedarán sin tipo."
class="btn btn-xs btn-error btn-outline"><x-heroicon-o-trash class="w-3.5 h-3.5" /></button>
</div>
</div>
</div>
@endforeach
</div>
@endif
{{-- Modal crear/editar --}}
@if($showForm)
<div class="fixed inset-0 z-40 bg-black/50" wire:click="$set('showForm', false)"></div>
<div class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div class="bg-base-100 rounded-box shadow-2xl w-full max-w-md">
<div class="flex items-center justify-between p-4 border-b border-base-300">
<h3 class="font-bold">{{ $editingId ? 'Editar tipo' : 'Nuevo tipo' }}</h3>
<button wire:click="$set('showForm', false)" class="btn btn-sm btn-ghost btn-circle"><x-heroicon-o-x-mark class="w-4 h-4" /></button>
</div>
<form wire:submit.prevent="save" class="p-4 space-y-3">
<div class="form-control">
<label class="label"><span class="label-text font-medium">Nombre <span class="text-error">*</span></span></label>
<input type="text" wire:model="name" autofocus class="input input-bordered w-full @error('name') input-error @enderror" placeholder="Ej.: Pilar" />
@error('name')<span class="text-xs text-error">{{ $message }}</span>@enderror
</div>
<div class="form-control">
<label class="label"><span class="label-text font-medium">Descripción</span></label>
<input type="text" wire:model="description" class="input input-bordered w-full" />
</div>
<div class="form-control">
<label class="label"><span class="label-text font-medium">Color</span></label>
<input type="color" wire:model="color" class="input input-bordered w-full h-12 p-1" />
</div>
<div class="flex justify-end gap-2 pt-2 border-t border-base-300">
<button type="button" wire:click="$set('showForm', false)" class="btn btn-ghost btn-sm">Cancelar</button>
<button type="submit" class="btn btn-primary btn-sm">Guardar</button>
</div>
</form>
</div>
</div>
@endif
</div>
@@ -36,6 +36,12 @@
<x-heroicon-o-map class="w-4 h-4" />
Mapa
</a>
@can('edit layers')
<a href="{{ route('projects.features', $project) }}" class="btn btn-outline btn-sm gap-1">
<x-heroicon-o-cube class="w-4 h-4" />
Elementos
</a>
@endcan
@can('edit projects')
<a href="{{ route('projects.templates', $project) }}" class="btn btn-outline btn-sm gap-1">
<x-heroicon-o-clipboard-document-list class="w-4 h-4" />
+4
View File
@@ -83,6 +83,10 @@ Route::get('/reports/dashboard', ReportsDashboard::class)->name('reports.dashboa
// Rutas para el LayerManager:
Route::get('/projects/{project}/phases/{phase}/layers/manage', \App\Livewire\Layers\LayerManager::class)->name('layers.manage');
// Elementos del proyecto y catálogo de tipos de elemento
Route::get('/projects/{project}/features', \App\Livewire\Projects\FeatureManager::class)->middleware('can:edit layers')->name('projects.features');
Route::get('/feature-types', \App\Livewire\Projects\FeatureTypeManager::class)->middleware('can:edit layers')->name('feature-types');
// Cronograma Gantt y reporte del proyecto
Route::get('/projects/{project}/gantt', PhaseGantt::class)->name('projects.gantt');
Route::get('/projects/{project}/report', [ProjectReportController::class, 'show'])->name('projects.report');
+125
View File
@@ -0,0 +1,125 @@
<?php
namespace Tests\Feature;
use App\Livewire\Projects\FeatureManager;
use App\Livewire\Projects\FeatureTypeManager;
use App\Livewire\Projects\ProjectFeaturesTable;
use App\Models\Feature;
use App\Models\FeatureType;
use App\Models\Layer;
use App\Models\Phase;
use App\Models\Project;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Spatie\Permission\Models\Permission;
use Tests\TestCase;
class FeatureManagementTest extends TestCase
{
use RefreshDatabase;
private User $user;
private Project $project;
private Feature $feature;
protected function setUp(): void
{
parent::setUp();
Permission::findOrCreate('edit layers');
$this->user = User::factory()->create();
$this->user->givePermissionTo('edit layers');
$this->project = Project::create([
'reference' => 'FT-1', 'name' => 'Proyecto Feat', 'address' => 'x',
'lat' => 40.0, 'lng' => -3.0, 'start_date' => now()->toDateString(),
'end_date_estimated' => now()->addMonth()->toDateString(),
'status' => 'in_progress', 'created_by' => $this->user->id,
]);
$this->project->users()->attach($this->user->id, ['role_in_project' => 'supervisor']);
$phase = Phase::create(['project_id' => $this->project->id, 'name' => 'F1', 'order' => 1, 'color' => '#000', 'progress_percent' => 0]);
$layer = Layer::create(['project_id' => $this->project->id, 'phase_id' => $phase->id, 'name' => 'Capa A', 'color' => '#111', 'uploaded_by' => $this->user->id]);
$this->feature = Feature::create([
'layer_id' => $layer->id, 'name' => 'Pilar 12',
'geometry' => ['type' => 'Point', 'coordinates' => [-3.0, 40.0]],
'progress' => 0, 'status' => 'planned', 'is_active' => true,
]);
}
// ── Catálogo de tipos ────────────────────────────────────────────────────────
public function test_feature_type_manager_creates_a_type(): void
{
Livewire::actingAs($this->user)
->test(FeatureTypeManager::class)
->call('newType')
->set('name', 'Pilar')
->set('color', '#ff0000')
->call('save')
->assertHasNoErrors();
$this->assertDatabaseHas('feature_types', ['name' => 'Pilar', 'color' => '#ff0000']);
}
public function test_feature_type_manager_requires_edit_layers(): void
{
$weak = User::factory()->create();
Livewire::actingAs($weak)
->test(FeatureTypeManager::class)
->assertForbidden();
}
// ── Editor de elementos ──────────────────────────────────────────────────────
public function test_features_table_lists_and_toggles_active(): void
{
Livewire::actingAs($this->user)
->test(ProjectFeaturesTable::class, ['projectId' => $this->project->id])
->assertOk()
->assertSee('Pilar 12')
->call('toggleActive', $this->feature->id);
$this->assertFalse($this->feature->fresh()->is_active);
}
public function test_feature_manager_edits_name_type_and_active(): void
{
$type = FeatureType::create(['name' => 'Viga', 'color' => '#00ff00']);
Livewire::actingAs($this->user)
->test(FeatureManager::class, ['project' => $this->project])
->call('editFeature', $this->feature->id)
->assertSet('name', 'Pilar 12')
->set('name', 'Pilar 12-B')
->set('featureTypeId', $type->id)
->set('isActive', false)
->call('save')
->assertHasNoErrors();
$f = $this->feature->fresh();
$this->assertEquals('Pilar 12-B', $f->name);
$this->assertEquals($type->id, $f->feature_type_id);
$this->assertFalse($f->is_active);
}
public function test_features_table_deletes_individual_feature(): void
{
Livewire::actingAs($this->user)
->test(ProjectFeaturesTable::class, ['projectId' => $this->project->id])
->call('deleteFeature', $this->feature->id);
$this->assertDatabaseMissing('features', ['id' => $this->feature->id, 'deleted_at' => null]);
}
public function test_feature_manager_forbidden_without_edit_layers(): void
{
$weak = User::factory()->create();
$this->project->users()->attach($weak->id, ['role_in_project' => 'viewer']);
Livewire::actingAs($weak)
->test(FeatureManager::class, ['project' => $this->project])
->assertForbidden();
}
}