Пример #1
0
 public function store(Request $request)
 {
     if (!$request->wantsJson()) {
         return response("Pings can only be created via json requests", 400);
     }
     sleep(1);
     $requestData = $request->all();
     $validator = Validator::make($requestData, ['name' => 'required|alpha_dash|max:255|unique:pings,name,NULL,id,deleted_at,NULL']);
     if ($validator->fails()) {
         /** @var \Illuminate\Validation\Validator $validator */
         return response($validator->getMessageBag(), 422);
     }
     $ping = Ping::createDefaultPing($requestData['name'], true, Auth::id());
     return Ping::findOrFail($ping->id);
 }