setup viste
This commit is contained in:
@@ -20,7 +20,40 @@ class MailingListController extends Controller
|
||||
|
||||
$mailingLists = $query->orderBy('nome')->get();
|
||||
$allTags = Tag::orderBy('name')->get();
|
||||
return view('mailing-liste.index', compact('mailingLists', 'allTags'));
|
||||
|
||||
$vista = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'mailing-liste')
|
||||
->where('is_default', true)
|
||||
->first();
|
||||
|
||||
$userVistas = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'mailing-liste')
|
||||
->orderBy('is_default', 'desc')
|
||||
->orderBy('nome')
|
||||
->get();
|
||||
|
||||
$allColumnDefs = [
|
||||
['key' => 'nome', 'label' => 'Nome'],
|
||||
['key' => 'descrizione', 'label' => 'Descrizione'],
|
||||
['key' => 'contatti_count', 'label' => 'Contatti'],
|
||||
['key' => 'tag', 'label' => 'Tag'],
|
||||
['key' => 'attiva', 'label' => 'Stato'],
|
||||
['key' => 'created_at', 'label' => 'Creata il'],
|
||||
];
|
||||
$defaultVisible = ['nome', 'descrizione', 'contatti_count', 'tag', 'attiva', 'created_at'];
|
||||
$visibleColumns = $vista && !empty($vista->colonne_visibili)
|
||||
? $vista->colonne_visibili
|
||||
: $defaultVisible;
|
||||
|
||||
$tableColumns = array_map(fn($col) => [
|
||||
'key' => $col['key'],
|
||||
'label' => $col['label'],
|
||||
'visible' => in_array($col['key'], $visibleColumns),
|
||||
], $allColumnDefs);
|
||||
$entityType = 'mailing-liste';
|
||||
$columnWidths = $vista && $vista->colonne_larghezze ? $vista->colonne_larghezze : [];
|
||||
|
||||
return view('mailing-liste.index', compact('mailingLists', 'allTags', 'vista', 'visibleColumns', 'tableColumns', 'entityType', 'columnWidths', 'userVistas'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
Reference in New Issue
Block a user