Repository URL to install this package:
|
Version:
0.2.1 ▾
|
<?php
namespace Modules\Courses\Http\Requests;
use Modules\Core\Http\Requests\Request;
class CadastroSlideRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;//policy(SlidesController::class)->create(Auth::user());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => 'required|max:100',
'slide_photo' => 'required|image',
'is_active' => 'boolean',
'course_id' => 'required|integer|exists:courses,id'
];
}
/**
* Sanitize input before validation.
*
* @return array
*/
public function sanitize()
{
$input = array_map('trim', $this->all());
if(!isset($input['is_active'])) {
$input['is_active'] = true;
}
if(isset($input['title'])){
$input['title'] = preg_replace('/\\.[^.\\s]{3,4}$/', '', $input['title']);
}
$this->replace($input);
return $this->all();
}
}