/** * Store a newly created resource in storage. * * @return Response */ public function store($society, SkillsRequest $request) { $skill = Skill::create($request->all()); $skill->society_id = $society; $skill->save(); return Redirect::route('society.skills.index', $society)->with('okmessage', 'New skill has been added'); }
/** * Run the database seeds. * * @return void */ public function run() { $skills = ['Designer', 'Developer', 'Engineer', 'Musician', 'Visual Artist', 'Filmmaker', 'Writer', 'Project Manager', 'Other']; foreach ($skills as $skillName) { $skill = Skill::create(['name' => $skillName]); $skill->save(); } }
/** * Ищет навык в БД или создает новый * * @param $skillName * @param $is_original * @return Skill */ public static function getOrCreateSkillByName($skillName, $is_original) { //ищем скилл с таким же именем $skill = self::where('name', $skillName)->first(); //если не нашли - добавляем ( только ключевые) if (!$skill && $is_original) { $skill = Skill::create(['name' => $skillName]); } return $skill; }