Added a validation rule to prevent duplicate directories being created

parent 42f25a1c
......@@ -3,13 +3,19 @@
namespace Modules\Media\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CreateFolderRequest extends FormRequest
{
public function rules()
{
return [
'name' => 'required',
'name' => [
'required',
Rule::unique('media__files', 'filename')->where(function ($query) {
return $query->where('is_folder', 1);
}),
],
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment