Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel request unique

<?php

namespace AppRequestsAdminProduct;

use AppRequestsBaseRequest;

class UpdateProductRequest extends BaseRequest
{
    public function rules()
    {
        //        dd();

        return [
            "title"            => "required|array",
            "title.*"          => "required|string",
            "content"          => "required|array",
            "content.*"        => "required|string",
            "meta_title"       => "required|array",
            "meta_title.*"     => "required|string",
            "meta_description" => "required|array",
            //            "meta_description.*" => "required|string",
            "meta_keyword"     => "required|array",
            "slug"             => "nullable|array",
            "slug.*"           => "required|string",
            //            "meta_keyword.*" => "required|string",
            "model"            => "required|string",
            "sku"              => "required|string|unique:products,sku,".$this->id,
            //            "price"            => "required|numeric|min:0",
            "quantity"         => "required|numeric|min:0",
            "min_quantity"     => "required|numeric|min:0",
            "warehouse"        => "required|boolean",
            "length"           => "required|string",
            "width"            => "required|string",
            "height"           => "required|string",
            "length_type"      => "required|integer|exists:length_classes,id",
            "weight"           => "required|string",
            "weight_type"      => "required|integer|exists:weight_classes,id",
            "status"           => "required|boolean",
            "sort_product"     => "required|integer|min:0",

            "manufacturer"  => "required|integer|exists:manufacturers,id",
            "category"      => "required|array",
            "category.*.id" => "required|integer|exists:category,id",
            //            "suppliers"     => "required|integer|exists:suppliers,id",

            "product_filter"      => "required|array",
            "product_filter.*.id" => "required|integer|exists:filter_values,id",

            "product_attribute"                => "array|nullable",
            "product_attribute.*.attribute_id" => "required|integer|exists:attributes,id",
            "product_attribute.*.text"         => "required|array",
            "product_attribute.*.text.*"       => "required|string",

            "product_option"             => "array|nullable",
            "product_option.*.required"  => "required|boolean",
            "product_option.*.option_id" => "required|integer|exists:options,id",

            "product_option.*.product_option_value"                   => "array|nullable",
            "product_option.*.product_option_value.*.option_value_id" => "required|integer|exists:option_values,id",
            "product_option.*.product_option_value.*.quantity"        => "required|integer|min:0",
            "product_option.*.product_option_value.*.subtract"        => "required|boolean",
            "product_option.*.product_option_value.*.price"           => "nullable|numeric|min:0",
            "product_option.*.product_option_value.*.price_prefix"    => "nullable|string|max:1",
            "product_option.*.product_option_value.*.points"          => "nullable|integer|min:0",
            "product_option.*.product_option_value.*.points_prefix"   => "nullable|string|max:1",
            "product_option.*.product_option_value.*.weight"          => "nullable|numeric|min:0",
            "product_option.*.product_option_value.*.weight_prefix"   => "nullable|string|max:1",

            "product_discount"              => "array|nullable",
            "product_discount.*.quantity"   => "required|numeric|min:1",
            "product_discount.*.priority"   => "required|string",
            "product_discount.*.price"      => "required|numeric|min:0",
            "product_discount.*.date_start" => "required|date",
            "product_discount.*.date_end"   => "required|date",

            "product_special"              => "array|nullable",
            "product_special.*.priority"   => "required|string",
            "product_special.*.price"      => "required|numeric|min:0",
            "product_special.*.date_start" => "required|date",
            "product_special.*.date_end"   => "required|date",

            "images"         => "array|required",
            "images.*.image" => "required|string",

            "product_price"               => "array|nullable",
            "product_price.*.supplier_id" => "required|numeric",
            "product_price.*.price"       => "required|string",

        ];
    }
}
 
PREVIOUS NEXT
Tagged: #laravel #request #unique
ADD COMMENT
Topic
Name
2+9 =