public function run() { $faker = Faker::create(); foreach (range(1, 100) as $index) { $client = Client::create(['name' => $faker->company, 'about' => $faker->sentence(), 'location' => $faker->city . ' ' . $faker->state, 'industry_id' => $faker->numberBetween(1, 10), 'agency_id' => $faker->numberBetween(1, 10)]); $staff = ClientStaff::create(['name' => $faker->firstName . ' ' . $faker->lastName, 'email' => $faker->email, 'type' => 'hr', 'client_id' => $client->id, 'telephone' => $faker->randomNumber(6)]); } }
/** * List Client Staff * @return \Illuminate\Http\JsonResponse */ public function index() { if (\Input::get('client_id')) { if (\Input::has('type')) { $staff = Client::find(\Input::get('client_id'))->staff()->whereType(\Input::get('type')->get()); } else { $staff = Client::find(\Input::get('client_id'))->staff; } return \Response::json(['data' => $staff]); } }
} }, '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(Client $client) { return ['id' => $client->id, 'name' => $client->name, 'about' => $client->about, 'contact_name' => $client->contact_name, 'contact_telephone' => $client->contact_telephone, 'contact_email' => $client->contact_email, 'logo_url' => $client->present()->logo_url, 'num_jobs' => count($client->jobs)]; }
/** * List Client Jobs * @return \Illuminate\Http\JsonResponse */ public function jobs($client_id) { $jobs = Client::find($client_id)->jobs()->with('skills')->paginate(); return $this->respondWithCollection($jobs, new JobTransformer(), ['skills']); }