/** * Run the database seeds. * * @return void */ public function run() { Profession::create(['name' => 'Back-End Developer']); Profession::create(['name' => 'Front-End Developer']); Profession::create(['name' => 'Full Stack Developer']); Profession::create(['name' => 'Designer']); Profession::create(['name' => 'Other']); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $data = $request->all(); $validator = $this->validator($data); if ($validator->fails()) { return response(['errors' => $validator->messages()], 400); } // store $profession = new Profession(); $newProfession = $profession->create($data); return response($newProfession, 201); }