laravel-vue-file-share/app/Http/Requests/RecycledFiles.php
2023-10-17 22:45:04 -07:00

33 lines
905 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth;
class RecycledFiles extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
// append rules to default validation rules
return [
'all' => 'bool', // all or not
'Ids.*' => Rule::exists('files', 'id') // check that file exists in database
->where(fn($query) => $query->where('created_by', Auth::id())) // check file was made by current user
];
}
}