Esempio n. 1
0
 /**
  * Store a newly created lingo in storage.
  *
  * @Post("/")
  * @Transaction(
  *     @Request({"phrase": "361", "definition": "..."}),
  *     @Response(201, body={"id": 2, "phrase": "361", "definition": "...", "url": "/lingo/2"}),
  *     @Response(422, body={"phrase": {"The phrase has already been taken."}})
  * )
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['phrase' => 'required|unique:lingo,phrase', 'definition' => 'required']);
     $lingo = new Lingo();
     $lingo->phrase = $request->input('phrase');
     $lingo->definition = $request->input('definition');
     $lingo->save();
     return new JsonResponse($lingo, Response::HTTP_CREATED);
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $lingo = new Lingo();
     $lingo->phrase = '261';
     $lingo->definition = '261 is the course number for Introduction to ' . 'Software Engineering, the SE course required by many programs ' . 'here at RIT.';
     $lingo->save();
     $lingo = new Lingo();
     $lingo->phrase = '361';
     $lingo->definition = '361 is the course number for the old Introduction ' . 'to Software Engineering, the SE course required by many programs ' . 'RIT back in the glory days of the quarter system.';
     $lingo->save();
 }