public function design() { $roles = Role::all(); $users = User::all(); $userroles = DB::table('role_user')->get(); $jobstable = Job::all(); $userjobs = Userjobs::all(); $permissions = DB::table('permissions')->get(); $permissionroles = DB::table('permission_role')->get(); $skills = Skill::all(); $jobskills = JobSkill::all(); $userskills = UserSkill::all(); return View('design')->withJobs($jobstable)->withJobsusers($userjobs)->withusers($users)->withroles($roles)->withuserroles($userroles)->withpermissions($permissions)->withpermissionroles($permissionroles)->withskills($skills)->withjobskills($jobskills)->withuserskills($userskills); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::create(); for ($i = 1; $i < 200; $i++) { $name = $faker->shuffle($faker->word()); $recodeID = $faker->boolean(50) ? rand(0, $i) : NULL; Character::create(['name' => $name, 'savename' => $name, 'class' => $faker->randomElement($array = array('A', 'B', 'C', 'D', 'S', 'SS', 'Z')), 'race' => $faker->boolean(50), 'pot' => $faker->boolean(50), 'pof' => $faker->boolean(50), 'adventurer' => $faker->boolean(50), 'recode_id' => NULL]); for ($t = 1; $t < 4; $t++) { Job::create(['name' => $faker->shuffle($faker->name()), 'number' => $t, 'element' => $faker->randomElement($array = array('None', 'Fire', 'Ice', 'Darkness', 'Lightning', 'Heal', 'Remedy')), 'weapon' => $faker->randomElement($array = array('Sword', 'Bow', 'Spear', 'Staff')), 'minHP' => $faker->numberBetween(0, 130), 'maxHP' => $faker->numberBetween(200, 900), 'minATK' => $faker->numberBetween(0, 130), 'maxATK' => $faker->numberBetween(200, 900), 'minDEF' => $faker->numberBetween(0, 130), 'maxDEF' => $faker->numberBetween(200, 900), 'minMATK' => $faker->numberBetween(0, 130), 'maxMATK' => $faker->numberBetween(200, 900), 'minMDEF' => $faker->numberBetween(0, 130), 'maxMDEF' => $faker->numberBetween(200, 900), 'character_id' => $i]); for ($s = 1; $s < 5; $s++) { $skillcount = Skill::all()->count(); $skill = Skill::where('id', rand(0, $skillcount - 1))->first(); JobSkill::create(['lvl' => rand(0, 15 * $s), 'skill_name' => $skill->name, 'affection' => $faker->word(), 'frequency' => rand(0, 101), 'job_id' => $t * $i]); $itemcount = Item::all()->count(); $item = Item::where('id', rand(0, $itemcount - 1))->first(); JobItem::create(['quantity' => rand(0, 51), 'item_name' => $item->name, 'job_id' => $t * $i]); } } for ($j = 0; $j < rand(1, 5); $j++) { Iteration::create(['trigger' => $faker->word(), 'content' => $faker->text(), 'character_id' => $i, 'trigger_id' => NULL]); } } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($company_id, $id, Request $request) { //dd($request->all()); $job = Job::find($id); $job->job_title = $request->input('job_title'); $job->creative_field = $request->input('creative_fields'); $job->location = $request->input('location'); $job->exp_date = $request->input('exp_date'); $job->pre_lang = $request->input('pre_lang'); $job->res_lang = $request->input('res_lang'); $job->salary = $request->input('salary'); $job->salary_from = $request->input('salary_from'); $job->salary_to = $request->input('salary_to'); $job->contact_gender = $request->input('contact_gender'); $job->contact_name = $request->input('contact_name'); $job->apply_email = $request->input('apply_email'); $job->job_desc = $request->input('description'); $job->apply_reason = $request->input('apply_reason'); $job->save(); /* Update job level */ $levels = $request->input('job_level'); $count_lev = sizeof($levels); for ($i = 0; $i < $count_lev; $i++) { $job_level = new JobLevel(); $job_level->job_id = $job->id; $job_level->level_id = $levels[$i]; $job_level->save(); } /* Update job types */ $edit_types = $request->input('job_type'); // stored in array $created_types = $job->job_types->list('type_id'); // compare 2 arrays $add_types = array_value(array_diff($edit_types, $created_types)); $delete_types = array_value(array_diff($created_types, $edit_types)); // add new types $count_typ = sizeof($add_types); for ($i = 0; $i < $count_typ; $i++) { $job_type = new JobType(); $job_type->job_id = $id; $job_type->type_id = $add_types[$i]; $job_type->save(); } // delete types $count_del = sizeof($delete_types); for ($i = 0; $i < $count_del; $i++) { $job_type = JobType::where('type_id', '=', $delete_types[$id])->first(); $job_type->delete(); } /* Update job skills */ $names = $request->input('skillnames'); $descs = $request->input('skilldescs'); $count_ski = sizeof($names); for ($i = 0; $i < $count_ski; $i++) { $jobskill = new JobSkill(); $jobskill->job_id = $job->id; $jobskill->name = $names[$i]; $jobskill->description = $descs[$i]; $jobskill->save(); } $company = Company::find($company_id); return view('jobs.show', compact('job', 'company')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $job = Job::find($id); $jobskills = JobSkill::where('job_id', $id)->get(); return view('jobs.show')->withJob($job)->withSkills($jobskills); }