I am doing all the validations in Model
My Rule is
public static $rules = array(
'VehicleNumber' => 'required|unique:vehicle',
'NumberSeats' => 'required',
'VehicleType' => 'required',
'MaximumAllowed' => 'numeric|max:3',
'VehicleCode' => 'required|unique:vehicle');
}
But for changing the file name and checking its size i am handling in a SetFooAttribute
public function setInsurancePhotoAttribute($InsurancePhoto)
{
if($InsurancePhoto && Input::file('InsurancePhoto')->getSize() < '1000')
{
$this->attributes['InsurancePhoto'] = Input::get('VehicleCode') . '-InsurancePhoto.' . Input::file('InsurancePhoto')->getClientOriginalExtension();
Input::file('InsurancePhoto')->move('assets/uploads/vehicle/', Input::get('VehicleCode') . '-InsurancePhoto.' . Input::file('InsurancePhoto')->getClientOriginalExtension());
}
}
There in the Condition
if($InsurancePhoto && Input::file('InsurancePhoto')->getSize() < '1000')
If it fails the Storing of Image, Setting Attribute won't be done.
But How can i throw the Error to the User in this Case ?