Exemplo n.º 1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Check if location has children
     if ($this->model->children->count()) {
         return JSend::fail(['children' => 'This location has ' . $this->model->children->count() . 'sublocations']);
     }
     // Allow to delete location
     return JSend::success($this->model);
 }
Exemplo n.º 2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // set validation rules
     $rules['name'] = ['required'];
     $rules['level'] = ['required', 'in:continent,country,province,city,suburb'];
     $rules['latitude'] = ['numeric'];
     $rules['longitude'] = ['numeric'];
     // validates
     $validator = Validator::make($this->model->toArray(), $rules);
     if ($validator->fails) {
         return JSend::fail($validator->messages()->toArray());
     } else {
         return JSend::success($this->model);
     }
 }