45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
|
|
<?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 ]);
|
||
|
|
}
|
||
|
|
}
|