richard
/
cyca
Archived
1
0
Fork 0
This repository has been archived on 2024-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
cyca/app/Http/Requests/Documents/StoreRequest.php

57 lines
1.2 KiB
PHP
Executable File

<?php
namespace App\Http\Requests\Documents;
use App\Models\Folder;
use App\Models\Group;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$folder = Folder::find($this->folder_id);
return $this->user()->can('createBookmarkIn', $folder);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'url' => [
'required',
'url',
],
'group_id' => [
'required',
Rule::exists(Group::class, 'id'),
],
'folder_id' => [
'required',
Rule::exists(Folder::class, 'id'),
],
];
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation()
{
$this->merge([
'url' => urldecode($this->url),
]);
}
}