Created
July 20, 2020 10:41
-
-
Save introqt/a5584b275f0fcad56baae2f25740480d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Modules\Product\Http\Requests\Admin\Product; | |
use App\Core\Requests\Admin\BaseAdminRequest; | |
use App\Rules\CheckExistsUrlIfNotFillUrl; | |
use Illuminate\Validation\Rule; | |
use Modules\Product\Entities\Product; | |
use Modules\Product\Entities\ProductVariation; | |
/** | |
* Class StoreCountryRequest | |
* | |
* @package Modules\Product\Http\Requests\Admin | |
*/ | |
class UpdateProductRequest extends BaseAdminRequest | |
{ | |
/** | |
* Determine if the user is authorized to make this request. | |
* | |
* @return bool | |
*/ | |
public function authorize() | |
{ | |
return backpack_auth()->check(); | |
} | |
/** | |
* Get the validation rules that apply to the request. | |
* | |
* @return array | |
*/ | |
public function rules() | |
{ | |
$product_table_name = (new Product())->getTable(); | |
$variations_table_name = (new ProductVariation())->getTable(); | |
return [ | |
'variations' => [ | |
'array', | |
], | |
'variations.*.h1' => [ | |
'required', | |
'string', | |
'min:0', | |
'max:255', | |
Rule::unique($product_table_name, 'h1')->ignore(\Request::instance()->id, "id"), | |
Rule::unique($variations_table_name, 'h1')->ignore(\Request::instance()->id, "id") | |
], | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment