Esempio n. 1
0
 public function create(array $data)
 {
     $validator = Validator::make($data, ['name' => 'required|string|min:1|max:255', 'description' => 'required|string', 'file' => 'required|regex:/^[\\w.-]{1,50}$/', 'executable' => 'max:255|regex:/^(.*)$/', 'startup' => 'string']);
     if ($validator->fails()) {
         throw new DisplayValidationException($validator->errors());
     }
     if (Models\Service::where('file', $data['file'])->first()) {
         throw new DisplayException('A service using that configuration file already exists on the system.');
     }
     $data['author'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
     $service = new Models\Service();
     $service->fill($data);
     $service->save();
     return $service->id;
 }