Club System
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Rules\PublicFileExists;
|
||||
use App\Rules\XfUserExists;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -49,12 +50,20 @@ class StoreEntryRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
$isEdit = (bool) $this->route('entry');
|
||||
|
||||
$rules = [];
|
||||
$section = $this->route('section');
|
||||
|
||||
$rules['files_uuid'] = 'array|required|min:1';
|
||||
$rules['files_uuid.*'] = 'string';
|
||||
|
||||
if( $isEdit ){
|
||||
$rules['files_state'] = 'array|required|min:1';
|
||||
$rules['files_state.*'] = 'string|in:public,private,archived';
|
||||
}
|
||||
|
||||
if( section_must_not_be( 'translations', $section ) ){
|
||||
$rules['entry_title'] = "required|string|max:255";
|
||||
} else {
|
||||
@@ -78,7 +87,6 @@ class StoreEntryRequest extends FormRequest
|
||||
$rules['new-game-genre'] = 'required_with:new-game-title|integer|nullable|exists:genres,id';
|
||||
}
|
||||
|
||||
|
||||
$rules['hashes'] = 'array|required|min:1';
|
||||
$rules['hashes.*.filename'] = 'required|string|max:512';
|
||||
$rules['hashes.*.hash_crc32'] = 'required|string|max:512';
|
||||
@@ -101,7 +109,25 @@ class StoreEntryRequest extends FormRequest
|
||||
$rules['release_site'] = 'nullable|url|max:500';
|
||||
$rules['youtube_video'] = 'nullable|url|max:500';
|
||||
|
||||
$rules['submit-state'] = 'required|string|in:draft,pending,published';
|
||||
if( $isEdit ){
|
||||
$ss = 'draft,pending,published';
|
||||
if( \Auth::user()->can('moderate', $this->route('entry')) && \Auth::user()->can('view-hidden', $this->route('entry')) )
|
||||
$ss .= ',hidden';
|
||||
if(\Auth::user()->can('moderate', $this->route('entry')) && \Auth::user()->can('view-locked', $this->route('entry')) )
|
||||
$ss .= ',locked';
|
||||
$rules['submit-state'] = 'required|in:' . $ss;
|
||||
} else {
|
||||
if( $this->user()->can('skip-queue', '\App\Models\Entry') ){
|
||||
$rules['submit-state'] = 'required|string|in:draft,pending,published';
|
||||
} else {
|
||||
$rules['submit-state'] = 'required|string|in:draft,pending';
|
||||
}
|
||||
}
|
||||
|
||||
if( $isEdit && $this->user()->can('moderate', $this->route('entry') ) ){
|
||||
$rules['staff_comment'] = 'nullable|string';
|
||||
$rules['owner_user_id'] = [ 'required', 'integer', new XfUserExists ];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user