|
|
@ -18,6 +18,7 @@ use DB; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Validation\Rule; |
|
|
|
use Illuminate\Validation\Rule; |
|
|
|
use MightyPork\Exceptions\NotApplicableException; |
|
|
|
use MightyPork\Exceptions\NotApplicableException; |
|
|
|
|
|
|
|
use MightyPork\Exceptions\SimpleValidationException; |
|
|
|
use MightyPork\Utils\Utils; |
|
|
|
use MightyPork\Utils\Utils; |
|
|
|
|
|
|
|
|
|
|
|
class TableController extends Controller |
|
|
|
class TableController extends Controller |
|
|
@ -131,7 +132,6 @@ class TableController extends Controller |
|
|
|
'name' => [ |
|
|
|
'name' => [ |
|
|
|
'required', |
|
|
|
'required', |
|
|
|
VALI_NAME, |
|
|
|
VALI_NAME, |
|
|
|
Rule::unique('tables')->ignoreModel($tableModel), |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
'title' => ['required', VALI_LINE], |
|
|
|
'title' => ['required', VALI_LINE], |
|
|
|
'description' => ['nullable', VALI_TEXT], |
|
|
|
'description' => ['nullable', VALI_TEXT], |
|
|
@ -139,6 +139,11 @@ class TableController extends Controller |
|
|
|
'origin' => ['nullable', VALI_TEXT], |
|
|
|
'origin' => ['nullable', VALI_TEXT], |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$otherTableNames = $user->tables()->get(['name'])->pluck('name')->diff([$table])->all(); |
|
|
|
|
|
|
|
if (in_array($input->name, $otherTableNames)) { |
|
|
|
|
|
|
|
return $this->backWithErrors(['name' => "You already have a table called \"$input->name\""]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$tableModel->fill($input->all()); |
|
|
|
$tableModel->fill($input->all()); |
|
|
|
$tableModel->save(); |
|
|
|
$tableModel->save(); |
|
|
|
|
|
|
|
|
|
|
@ -156,7 +161,6 @@ class TableController extends Controller |
|
|
|
'name' => [ |
|
|
|
'name' => [ |
|
|
|
'required', |
|
|
|
'required', |
|
|
|
VALI_NAME, |
|
|
|
VALI_NAME, |
|
|
|
Rule::unique('tables'), |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
'title' => ['required', VALI_LINE], |
|
|
|
'title' => ['required', VALI_LINE], |
|
|
|
'description' => ['nullable', VALI_TEXT], |
|
|
|
'description' => ['nullable', VALI_TEXT], |
|
|
@ -169,7 +173,7 @@ class TableController extends Controller |
|
|
|
// Check if table name is unique for user |
|
|
|
// Check if table name is unique for user |
|
|
|
if ($u->hasTable($input->name)) { |
|
|
|
if ($u->hasTable($input->name)) { |
|
|
|
return $this->backWithErrors([ |
|
|
|
return $this->backWithErrors([ |
|
|
|
'name' => "A table called \"$input->name\" already exists in your account.", |
|
|
|
'name' => "You already have a table called \"$input->name\"", |
|
|
|
]); |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|