<?php

namespace LaraBB\Category\UI\Web\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\RedirectResponse;
use LaraBB\Application\Traits\Request;

/**
 * Class Store
 * @package LaraBB\Category\UI\Web\Requests
 */
class Store extends FormRequest
{
    use Request;

    /**
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array
     */
    public function rules(): array
    {
        return $this->getRules('categories', ['uuid']);
    }

    /**
     * @return array
     */
    public function messages(): array
    {
        return $this->getMessages('categories', ['uuid']);
    }

    /**
     * @return RedirectResponse
     */
    public function success(): RedirectResponse
    {
        return redirect()->route('admin.forums')->with([
            'success'       => 'Die Kategorie wurde erfolgreich erstellt.',
            'alert-options' => 'aside'
        ]);
    }

    /**
     * @return RedirectResponse
     */
    public function failed(): RedirectResponse
    {
        return redirect()->route('admin.forums.category.create')->with([
            'error' => 'Die Kategorie konnte aufgrund einer technischen Störung nicht erstellt werden.',
        ]);
    }
}
