56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class StoreTestimonialRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Determine if the user is authorized to make this request.
|
||
|
|
*
|
||
|
|
* @return bool
|
||
|
|
*/
|
||
|
|
public function authorize()
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'client_name' => 'required',
|
||
|
|
'client_designation_company_name' => 'required',
|
||
|
|
'description' => 'required',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function messages(){
|
||
|
|
return [
|
||
|
|
'required' => 'The :attribute field is required.',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function validated()
|
||
|
|
{
|
||
|
|
if($this->client_images === 'male.jpg' || $this->client_images === 'female.png'){
|
||
|
|
$image = $this->client_images;
|
||
|
|
}
|
||
|
|
if($this->client_images === "One"){
|
||
|
|
if($this->has('client_images_one')){
|
||
|
|
$image = time() . '.' . $this->client_images_one->extension();
|
||
|
|
$this->client_images_one->move(public_path('/uploads/testimonials/images'), $image);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return array_merge(parent::validated(), [
|
||
|
|
'rating' => $this->rating,
|
||
|
|
'client_image' => $image
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|