Fixes #26
This commit is contained in:
parent
c616686fd6
commit
dd73555457
1 changed files with 9 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Requests\Bo\Documents;
|
||||
|
||||
use App\Enums\Documents\LangEnum;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
||||
|
||||
|
|
@ -28,6 +29,12 @@ class StoreDocumentRequest extends FormRequest
|
|||
$this->merge([
|
||||
'status' => $this->status ? true : false
|
||||
]);
|
||||
if (Document::query()->where('id', $this->document_id)->exists()) {
|
||||
$this->merge([
|
||||
'directory_id' => Document::query()->where('id', $this->document_id)
|
||||
->value('directory_id')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,8 +45,8 @@ class StoreDocumentRequest extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'directory_id' => 'sometimes|nullable|integer',
|
||||
'document_id' => 'sometimes|nullable|integer',
|
||||
'directory_id' => 'required|integer',
|
||||
'document_id' => 'sometimes:directory_id|nullable|integer',
|
||||
'title' => 'required|min:3|max:255',
|
||||
'type' => 'required|min:3|max:255',
|
||||
'path' => 'required|min:3|max:255',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue