コード例 #1
0
 /**
  * Turn this item object into a generic array
  *
  * @param Candidate $candidate
  * @return array
  */
 public function transform(Candidate $candidate)
 {
     $res = ['profile_id' => $candidate->id, 'about' => $candidate->about, 'date_of_birth' => $candidate->date_of_birth, 'residency' => $candidate->residency, 'telephone' => $candidate->telephone, 'mobile' => $candidate->mobile, 'years_of_experience' => $candidate->years_of_experience, 'nationality' => $candidate->nationality, 'has_work_permit' => $candidate->has_work_permit, 'is_married' => $candidate->is_married, 'num_children' => $candidate->num_children, 'has_drivers_license' => $candidate->has_drivers_license, 'is_available' => $candidate->is_available, 'is_employed' => $candidate->is_employed, 'location_name' => $candidate->location_name, 'social_facebook' => $candidate->social_facebook, 'social_linked_in' => $candidate->social_linked_in, 'social_twitter' => $candidate->social_twitter, 'social_google_plus' => $candidate->social_google_plus, 'social_instagram' => $candidate->social_instagram, 'social_youtube' => $candidate->social_youtube, 'profile_pic_url' => $candidate->present()->profile_pic_url, 'age' => $candidate->age, 'expected_salary' => $candidate->expected_salary, 'is_external_vcard' => $candidate->is_external_vcard, 'profile_url' => $candidate->profile_url];
     if ($candidate->user) {
         $res['name'] = $candidate->user->first_name . ' ' . $candidate->user->last_name;
     }
     return $res;
 }
コード例 #2
0
 public function run()
 {
     $faker = Faker::create();
     $candidates = Candidate::lists('id');
     User::create(['username' => "demoguy", 'first_name' => "demo", 'last_name' => "guy", 'email' => "*****@*****.**", 'password' => 'secret', 'confirmed' => 1, 'userable_type' => 'Motibu\\Models\\Candidate', 'userable_id' => 1]);
     foreach (range(2, 10) as $index) {
         User::create(['username' => $faker->userName(), 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->email(), 'password' => 'secret', 'confirmed' => 1, 'userable_type' => 'Motibu\\Models\\Candidate', 'userable_id' => $faker->randomElement($candidates)]);
     }
     $users = User::all();
     foreach (range(1, 10) as $index) {
         $users[$index - 1]->agencies()->attach($index);
         $users[$index - 1]->roles()->attach(4);
         // agency admin
     }
     $locations = [['location' => "Piarco International Airport (POS), Golden Grove Road, Piarco, Trinidad and Tobago", 'latitude' => 10.5976964, 'longitude' => -61.339527], ['location' => "Pos, Jalan Semeru Selatan, Dampit, Malang 65181, Republic of Indonesia", 'latitude' => -8.2109083, 'longitude' => 112.7520661], ['location' => "Pos, Jalan W. Monginsidi, Kendari, Kota Kendari 93127, Republic of Indonesia", 'latitude' => -3.970164, 'longitude' => 122.588356], ['location' => "Pos, Jalan Raya Sumorame, Candi, Kabupaten Sidoarjo 61271, Republic of Indonesia", 'latitude' => -7.4936845, 'longitude' => 112.7057069], ['location' => "New Delhi, Delhi, India", 'latitude' => 28.6139391, 'longitude' => 77.2090212], ['location' => "Delhi, Haixi, Qinghai, China", 'latitude' => 37.369436, 'longitude' => 97.360985], ['location' => "Delhi, NY 13753, USA", 'latitude' => 42.27814009999999, 'longitude' => -74.91599459999999]];
     // create candidates
     foreach (range(1, 10) as $index) {
         $randLoc = $faker->randomElement($locations);
         $user = User::create(['username' => $faker->userName(), 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $index == 1 ? "*****@*****.**" : $faker->email(), 'password' => 'secret', 'confirmed' => 1]);
         $user->roles()->attach(3);
         // candidate
         Candidate::create(['user_id' => 10 + $index, 'residency' => $faker->city . ', ' . $faker->state . ' ' . $faker->country, 'telephone' => '5553882838', 'about' => $faker->paragraph(), 'location_name' => $randLoc['location'], 'location_latitude' => $randLoc['latitude'] * 1000, 'location_longitude' => $randLoc['longitude'] * 1000]);
     }
     // create agents
     foreach (range(1, 10) as $index) {
         foreach (range(1, 2) as $bleh) {
             $user = User::create(['username' => $faker->userName(), 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->email(), 'password' => 'secret', 'confirmed' => 1]);
             $user->roles()->attach(5);
             // agent
             Agent::create(['user_id' => $user->id, 'telephone' => '5553882838', 'agency_id' => $index, 'name' => $user->first_name . ' ' . $user->last_name]);
             // \DB::table('agent_to_job')->insert( [
             //     'user_id' => $user->id,
             //     'job_id' => $faker->numberBetween(1, 50)
             // ]);
         }
     }
     // Create a Super Admin
     $super = User::create(['username' => "demosuper", 'first_name' => "demo", 'last_name' => "guy", 'email' => "*****@*****.**", 'password' => 'secret', 'confirmed' => 1, 'userable_type' => 'Motibu\\Models\\Candidate', 'userable_id' => 1]);
     $super->roles()->attach(1);
     Plan::create(['title' => 'Basic', 'description' => 'Monthly Basic Plan', 'duration' => '30', 'cost_in_cents' => 2000, 'meta' => '{"can_contact_candidates": "true", "number_of_jobs_per_month": "5"}']);
 }
コード例 #3
0
 public function register()
 {
     $success = false;
     $user = Input::only('email', 'password', 'confirm_password', 'first_name', 'last_name');
     $user['username'] = $user['email'];
     Log::info(Input::all());
     try {
         if ($this->userValidator->validate($user)) {
             $newUser = User::create($user);
             $success = $newUser == true;
             // $success = $success &&
             $newUser->roles()->attach(Role::findByName('Candidate')->id);
             if ($this->candidateValidator->validate(['user_id' => $newUser->id])) {
                 $is_external_vcard = 0;
                 if (Input::get("is_external_vcard") == 'true') {
                     $is_external_vcard = 1;
                 }
                 $success = $success && Candidate::create(['user_id' => $newUser->id, "is_external_vcard" => $is_external_vcard]) == true;
                 //Moticardtoken::create(['user_id' => $newUser->id,"token"=>md5("{$newUser->id}".time())]);
                 $mtoken = new Moticardtoken();
                 $mtoken->user_id = $newUser->id;
                 $mtoken->token = md5("{$newUser->id}" . time());
                 $mtoken->save();
             }
         }
     } catch (FormValidationException $e) {
         return \Response::json(['success' => false, 'errors' => $e->getErrors(), 400]);
     }
     Log::info(print_r($user, true));
     if ($success) {
         $newUser->confirmation_code = Hash::make($newUser->id . str_random(30));
         $newUser->save();
         Mail::send('emails.registration.confirmation', ['confirmation' => base64_encode($newUser->confirmation_code), 'client_base_url' => Input::get('client_base_url')], function ($message) {
             $message->to(Input::get('email'))->subject('Verify your email address');
         });
     }
     return \Response::json(['success' => $success]);
 }
コード例 #4
0
 /**
  * List Candidates
  * @return \Illuminate\Http\JsonResponse
  */
 public function index()
 {
     if (\Input::get('job_id')) {
         $candidates = Job::find(\Input::get('job_id'))->candidates;
         return $this->respondWithCollection($candidates, new CandidateTransformer());
     } else {
         $candidates = Candidate::paginate();
         return $this->respondWithCollection($candidates, new CandidateTransformer());
     }
 }
コード例 #5
0
ファイル: routes.php プロジェクト: nilove/motibubackend
                $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitude)) * cos(deg2rad($d->location_latitude)) * sin($dLon / 2) * sin($dLon / 2);
                $c = 2 * asin(sqrt($a));
                $distance = $earth_radius * $c;
                if ($distance <= 100) {
                    $userIds[] = $d->user_id;
                }
            }
        }
        // subsequent filters will be using the $userIds variable
        if (!empty($userIds) && !empty($skilbaseids)) {
            $userIds = array_intersect($userIds, $skilbaseids);
        } elseif (!empty($skilbaseids)) {
            $userIds = $skilbaseids;
        }
        Log::info($userIds);
        $users = \Motibu\Models\Candidate::with('user')->whereIn('user_id', $userIds)->paginate();
        $fractal = new \League\Fractal\Manager();
        $collection = $users->getCollection();
        $resource = new \League\Fractal\Resource\Collection($users, new \Motibu\Transformers\CandidateTransformer());
        $resource->setPaginator(new \League\Fractal\Pagination\IlluminatePaginatorAdapter($users));
        $rootScope = $fractal->createData($resource);
        return \Response::json(['professionals' => $rootScope->toArray()]);
    });
    Route::post('/place_order', function () {
        // TODO: here's where you do the stripe parts
        // simply adding a subscription to an user
        return \Response::json(['success' => true]);
    });
});
/**
 * Base URL will be api.motibu.com