/** * Bootstrap the application services. * * @return void */ public function boot() { Validator::extend('bus_brand', function ($attribute, $value, $parameters, $validator) { $busValidator = new BusValidator(); return $busValidator->isValidBrand($value); }); Validator::extend('bus_model', function ($attribute, $value, $parameters, $validator) { $brand = array_get($validator->getData(), 'brand', null); $busValidator = new BusValidator(); return $busValidator->isValidModel($brand, $value); }); }
public function beforeSave() { $busValidator = new BusValidator(); $this->capacity = $busValidator->getCapacity($this->brand, $this->model); }