31
common/Workspaces/Requests/CrupdateWorkspaceRequest.php
Executable file
31
common/Workspaces/Requests/CrupdateWorkspaceRequest.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Common\Workspaces\Requests;
|
||||
|
||||
use Auth;
|
||||
use Common\Core\BaseFormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CrupdateWorkspaceRequest extends BaseFormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
$required = $this->getMethod() === 'POST' ? 'required' : '';
|
||||
$ignore =
|
||||
$this->getMethod() === 'PUT' ? $this->route('workspace')->id : '';
|
||||
$userId = $this->route('workspace')
|
||||
? $this->route('workspace')->user_id
|
||||
: Auth::id();
|
||||
|
||||
return [
|
||||
'name' => [
|
||||
$required,
|
||||
'string',
|
||||
'min:3',
|
||||
Rule::unique('workspaces')
|
||||
->where('owner_id', $userId)
|
||||
->ignore($ignore),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user