public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Agency::create(['description' => $faker->sentence(), 'name' => $faker->company, 'industry_id' => $faker->numberBetween(1, 5000)]); } }
public function run() { $faker = Faker::create(); $agencies = Agency::lists('id'); foreach (range(1, 50) as $index) { $job = Job::create(['agency_id' => $faker->randomElement($agencies), 'title' => $faker->sentence(), 'slug' => $faker->unique()->slug, 'client_id' => $faker->numberBetween(1, 10), 'agent_id' => $faker->numberBetween(21, 40), 'hr_id' => $faker->numberBetween(1, 10), 'is_published' => true, 'about' => $faker->paragraph(), 'salary_range_to' => $faker->numberBetween(4000, 5000), 'salary_range_from' => $faker->numberBetween(1000, 2000), 'mandate_start' => time(), 'mandate_end' => time() + 86400, 'age_range_to' => 18, 'age_range_from' => 35, 'date_of_entry' => $faker->numberBetween(time() - 100000, time() + 100000), 'contract_type_id' => $faker->numberBetween(1, 3)]); foreach (range(1, 3) as $index) { $job->skills()->attach([$faker->numberBetween(1, 6000) => ['description' => $faker->sentence(), 'level' => $faker->numberBetween(1, 100)]]); } } }
public function showWelcome() { Auth::login(User::find(1)); dd(Auth::user()->hasMtmRole(Role::findByName('Agency Admin'))); dd(Agency::findByName('Dietrich, Koelpin and Weissnat')); $model = Agency::first(); echo $model->hasMtmUser(User::find(1), 'admins'); // dd($this->get_class()); // dd($this->getActionPermissions(get_class($this))); // return View::make('hello'); }
} }, 'client.show' => function ($clientId) { $client = Client::find($clientId); if (Auth::user()->hasMtmAgency(Agency::find($client->agency_id))) { return true; } }, 'agent.create' => function () { $agencyId = Input::get('agency_id', false); if ($agencyId && Auth::user()->hasMtmAgency(Agency::find($agencyId))) { return true; } }, 'staff.create' => function () { $clientId = \Input::get('client_id'); $client = Client::find($clientId); if (Auth::user()->hasMtmAgency(Agency::find($client->agency_id))) { return true; } }, 'staff.read' => function ($clientId) { $client = Client::find($clientId); if (Auth::user()->hasMtmAgency(Agency::find($client->agency_id))) { return true; } }, 'job.create' => function () { $clientId = \Input::get('client_id'); $client = Client::find($clientId); if (Auth::user()->hasMtmAgency(Agency::find($client->agency_id))) { return true; } }]); ACL::withRole('SaaS Client Admin')->grant(['*.create' => true, '*.read' => true, '*.update' => true, '*.delete' => true]); ACL::withRole('Super Admin')->grant(['*.create' => true, '*.read' => true, '*.update' => true, '*.delete' => true]);
/** * Turn this item object into a generic array * * @return array */ public function transform(Agency $agency) { return ['id' => $agency->id, 'name' => $agency->name, 'description' => $agency->description, 'num_employees_to' => $agency->num_employees_to, 'num_employees_from' => $agency->num_employees_from, 'legal_entity' => $agency->legal_entity, 'industry' => $agency->industry, 'reg_no' => $agency->reg_no, 'operational_hours_monday_from' => $agency->operational_hours_monday_from, 'operational_hours_monday_to' => $agency->operational_hours_monday_to, 'operational_hours_tuesday_from' => $agency->operational_hours_tuesday_from, 'operational_hours_tuesday_to' => $agency->operational_hours_tuesday_to, 'operational_hours_wednesday_from' => $agency->operational_hours_wednesday_from, 'operational_hours_wednesday_to' => $agency->operational_hours_wednesday_to, 'operational_hours_thursday_from' => $agency->operational_hours_thursday_from, 'operational_hours_thursday_to' => $agency->operational_hours_thursday_to, 'operational_hours_friday_from' => $agency->operational_hours_friday_from, 'operational_hours_friday_to' => $agency->operational_hours_friday_to, 'operational_hours_saturday_from' => $agency->operational_hours_saturday_from, 'operational_hours_saturday_to' => $agency->operational_hours_saturday_to, 'operational_hours_sunday_from' => $agency->operational_hours_sunday_from, 'operational_hours_sunday_to' => $agency->operational_hours_sunday_to, 'social_facebook' => $agency->social_facebook, 'social_linked_in' => $agency->social_linked_in, 'social_twitter' => $agency->social_twitter, 'social_google_plus' => $agency->social_google_plus, 'social_instagram' => $agency->social_instagram, 'social_youtube' => $agency->social_youtube, 'is_client' => $agency->is_client, 'banner_url' => $agency->present()->banner_url, 'logo_url' => $agency->present()->logo_url]; }
public function register_agency() { $success = false; $user = Input::only('email', 'password', 'confirm_password', 'first_name', 'last_name'); $user['username'] = $user['email']; // $user['confirmation_code'] = $confirmation_code = str_random(30); Log::info(print_r($user, true)); try { if ($this->userValidator->validate($user)) { $newUser = User::create($user); $success = $newUser == true; $newUser->roles()->attach(Role::findByName('Agency Admin')->id); $agency['name'] = Input::get('agency_name'); $agency['description'] = 'new agency'; // try { if ($this->agencyValidator->validate($agency)) { Log::info($agency); $newAgency = Agency::create($agency); $newAgency->admins()->attach($newUser->id); } // } catch (FormValidationException $e) { // Log::info(print_r($e->getErrors())); // return \Response::json(['success' => false, 'error' => $e->getErrors()]); // } } } 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) . '?next_step=3&user_id=' . $newUser->id, '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]); }
/** * List agents * @return \Illuminate\Http\JsonResponse */ public function agents($agency_id) { $agency = Agency::findOrFail($agency_id); //print_r($agency); $agents = $agency->agents()->paginate(); //Log::info($agents); return $this->respondWithCollection($agents, new AgentTransformer()); }