public function edit($id) { $request = Request::with(['equipment', 'area', 'location', 'category', 'uploads', 'approvers', 'status', 'actions' => function ($query) { $query->orderBy('created_at', 'desc'); }, 'actions.submitted', 'comments.author' => function ($query) { $query->orderBy('created_at', 'asc'); }])->find($id); if (is_null($request)) { return view('security.not-found'); } $data['request'] = $request; $data['areas'] = Area::all(['id', 'name']); $data['organizations'] = Organization::all(); $data['categories'] = Category::all(['id', 'name']); $data['locations'] = Location::all(['id', 'name']); $data['approvers'] = Approval::getRecent($id); $data['hasApproved'] = Approval::hasApproved($id)->exists(); if ($request->Status->name == 'Approved') { return view('request.view', $data); } if ($request->submitted_by != Auth::User()->id && !Auth::User()->hasRole(['administrator', 'approver'])) { return view('security.401'); } return view('request.edit', $data); }
public function users() { $users = User::with('organization', 'roles')->get(['id', 'name', 'email', 'organization_id']); $orgs = Organization::all(); $roles = Role::all(); return Datatables::of($users)->addColumn('organization', function ($user) use($orgs) { $orgSelect = '<select name="organization" class="form-control organization" data-userid="' . $user->id . '">'; foreach ($orgs as $org) { $select = ""; if ($org->id == $user->organization_id) { $select = 'selected'; } $orgSelect .= '<option value="' . $org->id . '" ' . $select . '>' . $org->name . '</option>'; } $orgSelect .= '</select>'; //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->organization->name.'</a>'; return $orgSelect; })->addColumn('role', function ($user) use($roles) { $roleSelect = '<select name="organization" class="form-control role" data-userid="' . $user->id . '">'; foreach ($roles as $role) { $select = ""; if ($user->hasRole($role->name)) { $select = 'selected'; } $roleSelect .= '<option value="' . $role->id . '" ' . $select . '>' . $role->display_name . '</option>'; } $roleSelect .= '</select>'; //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->roles[0]->display_name.'</a>'; return $roleSelect; })->removeColumn('id')->removeColumn('organization_id')->make(true); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { try { return view('credential.edit', ['credential' => Credential::findOrFail($id), 'organizations' => Organization::all()]); } catch (\Exception $e) { return redirect()->back()->withError('Could not locate credential.'); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { if (Gate::denies('adminOnly')) { abort(403); } // Retrieve all the organizations in the database and return them return Organization::all(); }
public function index() { $heads = Head::lists('name', 'id'); $notes = Note::latest('id')->paginate(20); $bizs = Busines::all(); $orgs = Organization::all(); $forumHeads = forumHead::all(); return view('admin.index', compact('notes', 'bizs', 'orgs', 'forumHeads', 'heads')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(\Request $request) { if ($request::isMethod('post')) { $validator = Validator::make(Input::all(), District::$groupUpdateRules); //if ($validator->passes()) { @TODO fix this to accept array in Group::$groupUpdateRules if ($validator->passes()) { if (District::updateGroups($request)) { return Redirect::to('/districts')->with('message', 'The following errors occurred')->withErrors('Update success')->with('flag', 'success'); } return Redirect::to('/districts')->with('message', 'The following errors occurred')->withErrors('Update failed')->with('flag', 'danger'); } return Redirect::to('/districts')->with('message', 'The following errors occurred')->withErrors($validator)->withInput()->with('flag', 'danger'); } $allorganizations = Organization::all(); $data = District::with('organization')->paginate(25); return view('districts/all', compact('data', 'allorganizations')); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->truncate(); DB::table('role_user')->truncate(); $faker = Faker::create(); $orgs = Organization::all()->lists('id')->toArray(); User::create(['name' => 'Christopher Carver', 'email' => '*****@*****.**', 'organization_id' => '1', 'password' => bcrypt('3l1t3')]); /* foreach(range(1,100) as $index) { $user = User::create([ 'name' => $faker->name, 'email' => $faker->email, 'organization_id' => $faker->randomElement($orgs), 'password' => str_random(10), 'remember_token' => str_random(10), ]); $user->attachRole(3); } */ User::find(1)->attachRole(1); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $organizations = Organization::all(); return view('organization.index', compact('organizations')); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('results')->delete(); DB::table('group_indicator')->delete(); DB::table('group_user')->delete(); DB::table('indicator_organization')->delete(); DB::table('indicator_report')->delete(); DB::table('report_user')->delete(); DB::table('users')->delete(); DB::table('organizations')->delete(); DB::table('roles')->delete(); DB::table('indicators')->delete(); DB::table('groups')->delete(); DB::table('reports')->delete(); $roles = array(['name' => 'admin', 'display_name' => 'Admin'], ['name' => 'manager', 'display_name' => 'Manager'], ['name' => 'employee', 'display_name' => 'Employee']); foreach ($roles as $role) { Role::create($role); } $faker = Faker::create('pl_PL'); $indicators = array(['name' => 'Wydane skierowania', 'function_name' => 'wyd_skier_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba skierowań wydanych przez pracownika w badanym okresie.'], ['name' => 'Obsłużone wizyty', 'function_name' => 'obsluz_wiz_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba wizyt obsłużonych przez pracownika w badanym okresie.'], ['name' => 'Udzielone ind. porady zawodowe', 'function_name' => 'ind_por_zaw_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba indywidualnych porad zawodowych udzielonych przez pracownika w badanym okresie.'], ['name' => 'Udzielone grupowe porady zawodowe', 'function_name' => 'grup_por_zaw_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba grupowych porad zawodowych udzielonych przez pracownika w badanym okresie.'], ['name' => 'Udzielone indywidualne inf. zawodowe', 'function_name' => 'ind_inf_zaw_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba indywidualnych informacji zawodowych udzielonych przez pracownika w badanym okresie.'], ['name' => 'Zorganizowane grupowe inf. zawodowe', 'function_name' => 'grup_inf_zaw_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba grupowych informacji zawodowych zorganizowanych przez pracownika w badanym okresie.'], ['name' => 'Badania kwest. do profilowania', 'function_name' => 'bad_kwest_prof_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba badań kwestionariuszem do profilowania przeprowadzonych przez pracownika w badanym okresie.'], ['name' => 'Sporządzone IPD', 'function_name' => 'sporz_ipd_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba indywidualnych planów działania sporządzonych przez pracownika w badanym okresie.'], ['name' => 'Zarejestrowani kontrahenci', 'function_name' => 'zarej_kontr_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba kontrahentów zarejestrowanych przez pracownika w badanym okresie.'], ['name' => 'Kontakty z kontrahentami', 'function_name' => 'kont_kontr_001', 'type' => 'value', 'default_coefficient' => 1, 'description' => 'Liczba kontaktów z kontrahentami zrealizowanych przez pracownika w badanym okresie.']); foreach ($indicators as $indicator) { Indicator::create($indicator); } $organizations = array(['code' => 'demo', 'name' => 'Powiatowy Urząd Pracy Demo', 'active' => true], ['code' => '24780', 'name' => 'Powiatowy Urząd Pracy w Zabrzu', 'active' => true]); foreach ($organizations as $organization) { $newOrganization = Organization::create($organization); foreach (Indicator::all() as $indicator) { $newOrganization->indicators()->attach($indicator->id, ['coefficient' => $faker->randomFloat(3, 0, 10)]); } } foreach (range(1, 50) as $index) { $organization = Organization::all()->random(1); $gender = $faker->randomElement(['male', 'female']); $lastName = $faker->lastName($gender); $user = User::create(['login' => $organization->code . '_' . $faker->numerify($lastName . '###'), 'name' => $faker->firstName($gender), 'surname' => $lastName, 'password' => Hash::make('secret'), 'active' => $faker->boolean(), 'organization_id' => $organization->id]); $role = Role::all()->random(1); $user->attachRole($role); } foreach (Organization::all() as $organization) { foreach (range(1, rand(5, 10)) as $index) { $group = Group::create(['organization_id' => $organization->id, 'name' => $faker->numerify('Grupa testowa ####')]); $users = $organization->users()->orderBy(DB::raw('random()'))->take(rand(5, 10))->get(); foreach ($users as $user) { $group->users()->attach($user->id); } $indicators = Indicator::all()->random(rand(3, 7)); foreach ($indicators as $indicator) { $group->indicators()->attach($indicator->id); } } } $managers = User::whereHas('roles', function ($role) { $role->where('name', 'manager'); })->get(); foreach ($managers as $manager) { foreach (range(1, rand(3, 6)) as $index) { $endDate = $faker->dateTimeThisDecade(); $report = Report::create(['owner_id' => $manager->id, 'name' => $faker->numerify('Raport testowy ####'), 'start_date' => $faker->dateTimeThisDecade($endDate), 'end_date' => $endDate]); $indicators = Indicator::all()->random(rand(2, 5)); foreach ($indicators as $indicator) { $report->indicators()->attach($indicator->id, ['show_value' => $faker->boolean(), 'show_points' => $faker->boolean()]); } $users = $manager->organization->users()->orderBy(DB::raw('random()'))->take(rand(5, 10))->get(); foreach ($users as $user) { $report->users()->attach($user->id, ['view_self' => $faker->boolean(), 'view_all' => $faker->boolean()]); } } } Model::reguard(); }
<?php /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ use App\Organization; $factory->define('App\\User', function ($faker) { $orgs = Organization::all()->lists('id'); return ['name' => $faker->name, 'email' => $faker->email, 'organization_id' => $faker->randomElement($orgs), 'password' => str_random(10), 'remember_token' => str_random(10)]; }); $factory->define('App\\Request', function ($faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => str_random(10), 'remember_token' => str_random(10)]; }); $factory->define('App\\Organization', function ($faker) { return ['name' => $faker->company]; });
protected function getOrganizations() { $organizations = Organization::all(); return $organizations; }
/** * @return $this */ public function index() { $orgs = Organization::all(); return view('organizations/index')->with(['orgs' => $orgs]); }
public function getOrganizations() { $organizations = Organization::all(); return view("admin/organizations")->with("organizations", $organizations); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('results')->delete(); DB::table('group_indicator')->delete(); DB::table('group_user')->delete(); DB::table('indicator_organization')->delete(); DB::table('indicator_report')->delete(); DB::table('report_user')->delete(); DB::table('users')->delete(); DB::table('organizations')->delete(); DB::table('roles')->delete(); DB::table('indicators')->delete(); DB::table('groups')->delete(); DB::table('reports')->delete(); $roles = array(['name' => 'admin', 'display_name' => 'Admin'], ['name' => 'manager', 'display_name' => 'Manager'], ['name' => 'employee', 'display_name' => 'Employee']); foreach ($roles as $role) { Role::create($role); } $faker = Faker::create(); foreach (range(1, 5) as $index) { Indicator::create(['name' => $faker->sentence(3), 'function_name' => $faker->numerify($faker->sentence(3) . '###'), 'type' => $faker->randomElement(['value', 'ratio']), 'default_coefficient' => $faker->randomFloat(3, 0, 1), 'description' => $faker->text()]); } foreach (range(1, 5) as $index) { $organization = Organization::create(['code' => $faker->randomNumber(6), 'name' => $faker->company, 'active' => $faker->boolean()]); foreach (Indicator::all() as $indicator) { $organization->indicators()->attach($indicator->id, ['coefficient' => $faker->randomFloat(3, 0, 10)]); } } foreach (range(1, 100) as $index) { $organization = Organization::all()->random(1); $user = User::create(['login' => $organization->code . '_' . $faker->userName, 'name' => $faker->firstName, 'surname' => $faker->lastName, 'password' => Hash::make('secret'), 'active' => $faker->boolean(), 'organization_id' => $organization->id]); $role = Role::all()->random(1); $user->attachRole($role); } foreach (Organization::all() as $organization) { foreach (range(1, rand(5, 10)) as $index) { $group = Group::create(['organization_id' => $organization->id, 'name' => $faker->sentence(3)]); $users = $organization->users()->orderBy(DB::raw('random()'))->take(rand(5, 10))->get(); foreach ($users as $user) { $group->users()->attach($user->id); } $indicators = Indicator::all()->random(rand(2, 5)); foreach ($indicators as $indicator) { $group->indicators()->attach($indicator->id); } } } $managers = User::whereHas('roles', function ($role) { $role->where('name', 'manager'); })->get(); foreach ($managers as $manager) { foreach (range(1, rand(3, 6)) as $index) { $endDate = $faker->date('Y-m-d'); $report = Report::create(['owner_id' => $manager->id, 'name' => $faker->sentence(4), 'start_date' => $faker->date('Y-m-d', $endDate), 'end_date' => $endDate]); $indicators = Indicator::all()->random(rand(2, 5)); foreach ($indicators as $indicator) { $report->indicators()->attach($indicator->id, ['show_value' => $faker->boolean(), 'show_points' => $faker->boolean()]); } $users = $manager->organization->users()->orderBy(DB::raw('random()'))->take(rand(5, 10))->get(); foreach ($users as $user) { $report->users()->attach($user->id, ['view_self' => $faker->boolean(), 'view_all' => $faker->boolean()]); } } } Model::reguard(); }
public function index() { $organizations = Organization::all(); return view('organizations.index')->with('organizations', $organizations); }
public function getOrganizations() { $organizations = Organization::all(); return $organizations; }