51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateProjectStatusRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return ($this->token === \config('api.key')) && !\is_null($this->datas);
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation()
|
|
{
|
|
$data = \json_decode($this->datas, true);
|
|
$this->merge([
|
|
'project_uuid' => collect($data)->get('uuid'),
|
|
'sitemap' => collect($data)->get('sitemap') === 'true' ? true : false,
|
|
'robots' => collect($data)->get('robots') === 'true' ? true : false,
|
|
'code' => collect($data)->get('code'),
|
|
'logs' => collect($data)->get('logs')
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'project_uuid' => 'required|exists:projects,uuid',
|
|
'sitemap' => 'required|boolean',
|
|
'robots' => 'required|boolean',
|
|
'code' => 'required|array',
|
|
'logs' => 'required|numeric',
|
|
];
|
|
}
|
|
}
|