Файловый менеджер - Редактировать - /home/clickysoft/public_html/jm5-api.clickysoft.net/app/Rules/ValidateProductPrice.php
Назад
<?php namespace App\Rules; use App\Models\ProductPrice; use Illuminate\Contracts\Validation\DataAwareRule; use Illuminate\Contracts\Validation\InvokableRule; class ValidateProductPrice implements InvokableRule, DataAwareRule { /** * All of the data under validation. * * @var array */ protected $data = []; /** * Set the data under validation. * * @param array $data * @return $this */ public function setData($data) { $this->data = $data; return $this; } /** * Run the validation rule. * * @param string $attribute * @param mixed $value * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail * @return void */ public function __invoke($attribute, $value, $fail) { $product_id = str_replace('price_id', 'product_id', $attribute); $price = ProductPrice::where(['id' => $value, 'product_id' => request($product_id)])->first(); if (!$price) { return $fail('Invalid price id selected for product #:position.'); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка