File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/Properties/Requests/PropertyRequest.php
<?php declare(strict_types=1);
namespace App\Properties\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* Class PropertyRequest
*
* A request to create or update a property
*
* @package App\Properties\Requests
*/
class PropertyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return \Auth::check();
}
/**
* Get the validation rules that apply to the request.
* The structure is a bit based on the JSON API standard.
* @see https://jsonapi.org/
*
* @return array
*/
public function rules()
{
return [
'*.id' => 'sometimes|required|numeric',
'*.type' => 'sometimes|string',
'*.attributes.propertizable_id' => 'required|string',
'*.attributes.propertizable_type' => [
'required',
'string',
Rule::in([
'product',
'product_group',
'product_composite',
])
],
'*.attributes.id' => 'sometimes|required',
'*.relationships.key.attributes' => 'array',
'*.relationships.key.attributes.id' => 'sometimes|required',
'*.relationships.key.relationships.translations' => 'sometimes|array',
'*.relationships.key.relationships.translations.*.attributes.id' => 'sometimes|integer',
'*.relationships.key.relationships.translations.*.attributes.language_id' => 'sometimes|required|integer',
'*.relationships.key.relationships.translations.*.attributes.value' => 'sometimes|required',
'*.relationships.value.attributes.id' => 'sometimes|required',
'*.relationships.value.relationships.translations' => 'sometimes|array',
'*.relationships.value.relationships.translations.*.attributes.id' => 'sometimes|integer',
'*.relationships.value.relationships.translations.*.attributes.language_id' => 'required|integer',
'*.relationships.value.relationships.translations.*.attributes.value' => 'sometimes|required',
];
}
}