/** * Run the database seeds. * * @return void */ public function run() { // Create SkillType 'Work' $skilltype = SkillType::create(['name' => 'Work']); // Create SkillType 'Orgranisational' $skilltype = SkillType::create(['name' => 'Orgranisational']); // Create SkillType 'Other' $skilltype = SkillType::create(['name' => 'Other']); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(StoreNewSkillRequest $request, $id) { $data = $request->only(['description', 'skill', 'skilltype', 'enabled']); $data['skilltype'] = json_decode($data['skilltype'], true); // set the parameters correctly $data = ['name' => $data['skill'], 'description' => $data['description'], 'skilltype' => $data['skilltype'], 'enabled' => $data['enabled'] == 'true' ? 1 : 0]; $skill = Skill::where('user_id', '=', Auth::user()->id)->where('id', '=', $id)->first(); if ($skill != null) { $skill->update($data); } $skill->skill_type_id = SkillType::whereName($data['skilltype']['data']['skill'])->first()->id; $skill->save(); return response()->api('OK'); }