Файловый менеджер - Редактировать - /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Rules/SupplierProductNumberBelongsToProductPrice.php
Назад
<?php namespace App\Rules; use App\Models\ProductPrice; use Illuminate\Contracts\Validation\Rule; class SupplierProductNumberBelongsToProductPrice implements Rule { /** * Create a new rule instance. * * @return void */ public function __construct() { // } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { /*$product_prod_number = request()->route('product')->prices()?->where('supplier_prod_number', $value)->first(); $prod_number = ProductPrice::where('supplier_prod_number', $value)->first(); $flag = false; if ($product_prod_number && $prod_number){ $flag = $product_prod_number->id == $prod_number->id; } else if ($product_prod_number || !$prod_number){ $flag = true; } // return true if attribute belongs to the supplier_prod_number, false otherwise return $flag;*/ $prod_number = ProductPrice::where('supplier_prod_number', $value)->where('product_id', '<>', request()->route('product')?->id)->first(); return !$prod_number; } /** * Get the validation error message. * * @return string */ public function message() { return 'Invalid supplier production number for combination #:position.'; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка