Files
RomhackPlaza/app/View/Components/SubmitEntryStatus.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2026-05-20 18:25:15 +02:00
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class SubmitEntryStatus extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string $section
)
{
//
}
public function availableStates(): array
{
// TODO: Change for permissions.
return [
'draft' => "Save into my drafts",
'pending' => "Add to submissions queue",
'published' => "Publish it now"
];
}
public function defaultState(): string
{
$availableStates = array_keys( $this->availableStates() );
return in_array('published', $availableStates) ? 'published' : ( in_array('pending', $availableStates) ? 'pending' : 'draft' );
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.submit-entry-status', [ 'states' => $this->availableStates(), 'defaultState' => $this->defaultState(), 'section' => $this->section ]);
}
}