adrema/app/Contribution/Documents/ContributionDocument.php

66 lines
1.5 KiB
PHP
Raw Normal View History

2022-11-17 21:47:45 +01:00
<?php
namespace App\Contribution\Documents;
use Zoomyboy\Tex\Document;
2024-12-13 02:36:17 +01:00
use Zoomyboy\Tex\Template;
2022-11-17 21:47:45 +01:00
abstract class ContributionDocument extends Document
{
2024-12-13 02:16:09 +01:00
private string $eventName;
2022-11-17 21:47:45 +01:00
abstract public static function getName(): string;
2023-03-14 22:40:46 +01:00
/**
2023-05-17 00:22:43 +02:00
* @param ContributionRequestArray $request
2023-03-14 22:40:46 +01:00
*/
2023-03-14 22:42:12 +01:00
abstract public static function fromRequest(array $request): self;
2023-03-14 22:40:46 +01:00
2023-05-17 00:22:43 +02:00
/**
* @param ContributionApiRequestArray $request
*/
abstract public static function fromApiRequest(array $request): self;
/**
* @return array<string, mixed>
*/
abstract public static function rules(): array;
/**
* @return array<string, mixed>
*/
public static function globalRules(): array
{
return [
'members' => 'present|array|min:1',
'members.*' => 'integer|exists:members,id',
];
}
2024-12-13 02:16:09 +01:00
public static function buttonName(): string
{
return 'Für ' . static::getName() . ' erstellen';;
}
public function setEventName(string $eventName): void
{
$this->eventName = $eventName;
}
2024-12-13 02:28:41 +01:00
public function basename(): string
{
return str('Zuschüsse ')->append($this->getName())->append(' ')->append($this->eventName)->slug();
}
2024-12-13 02:36:17 +01:00
public function template(): Template
{
return Template::make('tex.templates.contribution');
}
2024-12-13 02:40:33 +01:00
public function view(): string
{
return 'tex.contribution.' . str(class_basename(static::class))->replace('Document', '')->kebab()->toString();
}
2022-11-17 21:47:45 +01:00
}