public function run() { $faker = Faker::create(); $skillId = App\Skill::lists('id')->toArray(); $jobId = App\Job::lists('id')->toArray(); foreach (range(1, 30) as $index) { \DB::table('job_skill')->insert(['job_id' => $faker->randomElement($skillId), 'skill_id' => $faker->randomElement($jobId)]); } }
}); // Authentication routes... Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin'); Route::get('auth/logout', 'Auth\\AuthController@getLogout'); // Registration routes... Route::get('auth/register', 'Auth\\AuthController@getRegister'); Route::post('auth/register', 'Auth\\AuthController@postRegister'); Route::post('/endpoint', function () { $data = json_decode(Request::input('mandrill_events'), true)[0]; if (isset($data['msg']['attachments'])) { unset($data['msg']['attachments']); } $User = App\User::firstOrCreate(['email' => $data['msg']['from_email'], 'name' => isset($data['msg']['from_name']) ? $data['msg']['from_name'] : 'N/A']); preg_match_all("#From:\\s\\w+\\s\\w+#", $data['msg']['text'], $matches); $Recruiter = null; if ($matches[0]) { $last_from = array_pop($matches[0]); $Recruiter = App\Recruiter::firstOrCreate(['name' => substr($last_from, 6)]); } $matches = []; $skills = App\Skill::lists('id', 'name')->toArray(); $string_regex = implode('|', array_keys($skills)); preg_match_all("#{$string_regex}#", $data['msg']['text'], $matches); $found_skills = array_unique($matches[0]); $message = App\Message::create(['user_id' => $User->id, 'body' => $data['msg']['text'], 'recruiter_id' => $Recruiter ? $Recruiter->id : '']); if ($found_skills) { $message->Skills()->attach(array_values(array_intersect_key($skills, array_flip($found_skills)))); } return Response::json(['success' => true]); });