/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { DB::beginTransaction(); $request['role'] = 'staff'; $result = $this->register($request); $value = $result->getData(); if (property_exists($value, 'error')) { return $result; } else { $staff = new Staff(); $staff['userId'] = $value->result->id; $staff['contactNumber'] = $request->input('contactNumber'); $staff['firstname'] = $request->input('firstname'); $staff['lastname'] = $request->input('lastname'); try { $staff->save(); } catch (\Exception $e) { DB::rollback(); return response()->json(['error' => ['message' => 'Error while saving Staff', 'code' => 400]]); } DB::commit(); $finalResult['id'] = $value->result->id; $finalResult['token'] = $value->result->token; return response()->json(['result' => $finalResult]); } }
public function create(Request $req) { $first_name = $req->get('first_name'); $last_name = $req->get('last_name'); $staff_nr = $req->get('staff_nr'); $staff = new Staff(); $staff->first_name = $first_name; $staff->last_name = $last_name; $staff->staff_nr = $staff_nr; $staff->save(); return view('useradded'); }
/** * Run the database seeds. * * @return void */ public function run() { /************** ADMIN DB ENTRY* **************/ $user = new User(); $user->username = "******"; $user->password = Hash::make('helloworld'); $user->level = 0; $user->save(); /************** TEACHER DB ENTRY* **************/ $user = new User(); $user->username = "******"; $user->password = Hash::make('helloworld'); $user->level = 2; $user->save(); /************** STUDENT DB ENTRY* **************/ $user = new User(); $user->username = "******"; $user->password = Hash::make('helloworld'); $user->level = 1; $user->save(); // $this->call(UsersTableSeeder::class); /************** STUDENT DB ENTRY* **************/ $student = new Student(); $student->name = "Sahil Kumar Maurya"; $student->username = "******"; $student->email = "*****@*****.**"; $student->phone_no = 1234567890; $student->admission_year = 2014; $student->course = "Bachelor of Technology"; $student->branch = "Computer Science Engineering"; $student->save(); /************** TEACHER DB ENTRY* **************/ $staff = new Staff(); $student->name = "S.K. Maurya"; $student->username = "******"; $student->email = "*****@*****.**"; $student->phone_no = 1234567890; $student->type = 1; $student->subject = "Networking"; $student->depart = "Computer Science Engineering"; $staff->save(); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); // Create a faker, add en_SG providers $faker->addProvider(new Faker\Provider\en_SG\Address($faker)); $faker->addProvider(new Faker\Provider\en_SG\Enhanced($faker)); $faker->addProvider(new Faker\Provider\en_SG\Person($faker)); $faker->addProvider(new Faker\Provider\en_SG\PhoneNumber($faker)); $faker->seed(9876); // Calling the same script twice with the same seed produces the same results // Insert 10 dummy records foreach (range(1, 10) as $index) { $gender = $faker->randomElement(['male', 'female']); $fullName = explode("|", $faker->unique()->nameWithSalutation($gender)); // Extract full name without salutation ("Full Name|Salutation" to array) $fullName = $fullName[0]; $emailName = strtolower(preg_replace('/\\s+/', '', $fullName)); // Remove whitespaces in full name, convert to lowercase strlen($emailName) > 8 ? $emailName = substr($emailName, 0, 8) : null; // Extract only 8 characters from full name $email = $emailName . '@centreforseniors.org.sg'; // 8 characters from full name + domain name Staff::create(['name' => $fullName, 'email' => $email, 'password' => bcrypt('qwerty1234'), 'is_admin' => $faker->boolean(25)]); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $staff_team = ''; $leader = ''; $pie_leader = ''; $department = ''; $department = Department::leftJoin('staff', 'department.id', '=', 'staff.department_id')->join('level', 'staff.level_id', '=', 'level.id')->join('role', 'level.role_id', '=', 'role.id')->select(DB::raw('department.name as name_dep,role.name,count(*) as num'))->groupBy('department.name', 'role.name')->get()->toArray(); $num_staff = $department; $pie = array(); foreach ($department as $value) { $pie[$value['name_dep']][] = array($value['name'], (int) $value['num']); } // is Leader if (Gate::allows('check-leader')) { $department = Department::leftJoin('staff', 'department.id', '=', 'staff.department_id')->join('level', 'staff.level_id', '=', 'level.id')->join('role', 'level.role_id', '=', 'role.id')->select(DB::raw('department.name as name_dep,role.name,count(*) as num'))->where(['department.id' => Auth::user()->department_id, 'department.active' => 1])->groupBy('department.name', 'role.name')->get()->toArray(); $num_staff = $department; $pie = array(); foreach ($department as $value) { $pie[$value['name_dep']][] = array($value['name'], (int) $value['num']); } } // is Developer // if is manager / != department / yourself // denied if (Gate::allows('check-developer')) { $staff = StaffTeam::where('staff_id', Auth::user()->id)->get()->first(); if (isset($staff) && !empty($staff)) { $staff_team = StaffTeam::where('team_id', $staff->team_id)->where('staff_id', '!=', Auth::user()->id)->get(); $team = Team::where('id', $staff->team_id)->get()->first(); $leader = Staff::find($team->creator); } } return view('admin.department.home', compact('pie', 'staff_team', 'leader', 'num_staff')); }
public function syncWithJira() { $staff_list = Staff::all(); Timelog::where('project_id', '=', $this->id)->delete(); $issue_service = new IssueService(app(ConfigurationInterface::class)); $start = 0; while (1) { try { $issues = $issue_service->search("project={$this->jira_key} and timespent>0 and updated >= {$this->start_date}", $start, 250, ["key", "worklog"]); } catch (JiraException $exception) { return false; } if (count($issues->getIssues()) == 0) { break; } $timelogs = []; foreach ($issues->getIssues() as $issue) { $jira_work_logs = $issue->fields->worklog->worklogs; foreach ($jira_work_logs as $jira_work_log) { if (!isset($jira_work_log->author)) { continue; } $employee = $staff_list->where('email', $jira_work_log->author->emailAddress)->first(); if ($employee == null) { continue; } $timelogs[] = ['project_id' => $this->id, 'staff_id' => $employee->id, 'time_spent' => $jira_work_log->timeSpentSeconds, 'jira_id' => $jira_work_log->id, 'started' => $jira_work_log->started]; } } Timelog::insert($timelogs); $start += count($issues->getIssues()); } return true; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['title'] = 'Home'; $data['home'] = 1; $staff = Staff::find(\Session::get('user')->staff_id); // dd($staff); if ($staff) { $classes = array('Please select a class'); foreach ($staff->classes as $class) { $classes[$class->id] = $class->name; } $data['classes'] = $classes; } if (session('user')->inRole('coder') || session('user')->inRole('principal')) { return view('dashboard', $data); } elseif (session('user')->inRole('head_teacher')) { return view('dashboard_head_teacher', $data); } elseif (session('user')->inRole('billing_officer')) { // return view('dashboard_billing_officer', $data); return redirect()->route('billing.fee_schedules.index'); } elseif (session('user')->inRole('admin_dept_officer')) { return view('dashboard_head_teacher', $data); } else { return view('unauthorized', $data); } }
/** * Execute the console command. * @return mixed */ public function handle() { $client = new Client(); //Call to EMS API to get the employee details $date = Carbon::yesterday()->format('Y-m-d'); //$date = '2016-03-03'; $ems_data = $client->get(env(APP_HOST) . "/" . EMS_API_PATH . 'employee_list/' . $date); if ($ems_data->getStatusCode() == STATUS_OK) { $data = json_decode($ems_data->getBody()->getContents()); foreach ($data as $key => $ems) { $staff = Staff::whereEmail($ems->employee_email_id)->first(); if (!empty($staff)) { //Find JIRA hours $worklog = Timelog::whereStaffId($staff->id)->whereStarted($date)->sum('time_spent'); $actual_jira_hours = gmdate('H:i:s', $worklog); $actual_ems_hours = $ems->actual_hours; //Comparing EMS and JIRA hours if ($actual_jira_hours != NULL && $actual_jira_hours != '00:00:00' && $actual_ems_hours != NULL && $actual_ems_hours != '00:00:00') { $diffrence = $actual_ems_hours - $actual_jira_hours; //IF difference is greater then 1 hour, then update EMS // Call back to EMS to mark employee as half absent $client->get(env(APP_HOST) . "/" . EMS_API_PATH . 'update_employee_timesheet/' . $ems->emp_id . '/' . $date . ($diffrence > ONE && $diffrence < FOUR) ? '/half' : '/full'); } } } } }
/** * Run the database seeds. * * @return void */ public function run() { $staffs = array(['name' => 'maxamed xaamud', 'tel' => '123-123-234', 'user_id' => '3']); foreach ($staffs as $staff) { Staff::create($staff); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($type, $id) { if ($id == 'video') { $events = Video::all(); return view('video.show', compact('events')); } elseif ($id == 'staff') { $events = Staff::all(); return view('staff.show', compact('events')); } elseif ($id == 'gallery') { $events = Image::all(); return view('gallery.show', compact('events')); } else { $event = Event::where('slug', $id)->where('type', $type)->first(); $location = Location::where('event_id', $event->id)->first(); $slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get(); $gallery = EventImage::where('event_id', $event->id)->first(); if ($event->type == $type) { if ($event->status == 1) { return view($type . '.show', compact('event', 'location', 'slider', 'gallery')); } else { return redirect('/' . $type . '/'); } } } }
public function create(\Request $request) { $data = Request::json()->all(); $issue_service = new IssueService(app(ConfigurationInterface::class)); $url_parts = parse_url($data['worklog']['self']); $uri = $url_parts['path']; $regex = '~^/rest/api/./issue/(?P<issue_id>.*?)/(?P<ignore>.*?)/?$~'; $matched = preg_match($regex, $uri, $matches); if (!$matched) { return null; } $issue = $issue_service->get($matches['issue_id']); $project_key = $issue->fields->project->key; $project = Project::whereJiraKey($project_key)->first(); $employee = Staff::whereUserName($data['worklog']['author']['name'])->first(); //return $project; $time_spent = $data['worklog']['timeSpentSeconds']; $started = $data['worklog']['started']; $timelog_jira_id = $data['worklog']['id']; $timelog = Timelog::whereJiraId($timelog_jira_id)->first(); if ($timelog == null) { $timelog = new Timelog(); } $timelog->project_id = $project->id; $timelog->staff_id = $employee->id; $timelog->started = $started; $timelog->time_spent = $time_spent; $timelog->jira_id = $timelog_jira_id; $timelog->save(); //debugInfo($timelog); return $timelog; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); DB::table('staff')->delete(); $user = User::create(array('username' => 'junia', 'password' => Hash::make('junia'))); $admin = Staff::create(array('user_id' => $user->id, 'firstname' => 'joel', 'lastname' => 'eyamu', 'phone' => '(078)4197544', 'email' => '*****@*****.**')); $user->staff()->associate($admin); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('staff')->truncate(); Staff::create(array('fname' => 'Umaha', 'lname' => 'Tokula', 'email' => '*****@*****.**', 'phone' => '08055271439', 'address' => 'No 7 Canaan Str, GRA, Gboko, Benue State', 'gender_id' => '1', 'staff_type_id' => '1', 'country_id' => '162', 'state_id' => '1', 'local_id' => '1')); $faker = Faker\Factory::create(); $limit = 30; for ($i = 0; $i < $limit; $i++) { Staff::create(['fname' => $faker->firstName, 'lname' => $faker->lastName, 'email' => $faker->unique()->email, 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'gender_id' => $faker->numberBetween($min = 1, $max = 2), 'staff_type_id' => $faker->numberBetween($min = 1, $max = 2), 'country_id' => $faker->numberBetween($min = 1, $max = 240), 'state_id' => $faker->numberBetween($min = 1, $max = 36), 'local_id' => $faker->numberBetween($min = 1, $max = 700)]); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Requests\UpdateAdminRequest $request, $id) { $staff = Staff::find($id); $updated = $staff->fill($request->input())->save(); if ($updated) { return \Redirect::route('show_profile', $id)->with('message', 'Profile successfuly Updated!'); } else { return \Redirect::route('edit_admin')->with('error-message', 'Failed to Update Profile!'); } }
public function create(Request $req) { $record = new Record(); $record->location_id = $req->get("location_id"); $staff = Staff::where("staff_nr", "=", $req->get("staff_id"))->first(); if ($staff == null) { return "oh fuk"; } $record->staff_id = $staff->id; $record->particularities = $req->get("particularities"); $record->save(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$this->auth->user()->is_admin) { // All staff that belongs to the centres that the authenticated user is in charge of $centreStaff = collect(Staff::ofCentres($this->auth->user())->get()->lists('staff_id')); // Redirect user if staff profile accessed is not in list if (!$centreStaff->contains($request->route()->parameter('staff'))) { return redirect('/staff'); } } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Auth::check()) { if (Auth::user()) { if ($request->ajax()) { return response('Unathorized.', 401); } else { $token = Input::get("token"); $user = Staff::get()->where('_token', '=', 'token'); return view('principal/profilePage', compact('user')); } } } return $next($request); }
/** * Handles registration process of new volunteer. * * @param \Illuminate\Http\Request $request * @return JSON array of status */ public function addUserAccount(Request $request) { Volunteer::create(['nric' => $request->get('nric'), 'name' => $request->get('name'), 'email' => $request->get('email'), 'password' => $request->get('password'), 'gender' => $request->get('gender'), 'date_of_birth' => $request->get('dob'), 'contact_no' => $request->get('phone'), 'occupation' => $request->get('occupation'), 'has_car' => $request->get('haveCar'), 'minutes_volunteered' => '0', 'area_of_preference_1' => $request->get('preferences1'), 'area_of_preference_2' => $request->get('preferences2'), 'image_nric_front' => $request->get('frontIC'), 'image_nric_back' => $request->get('backIC'), 'rank_id' => Rank::where('min', 0)->first()->rank_id]); $volunteer = Volunteer::where('email', $request->get('email'))->first(); $mailingList = Staff::where('is_admin', 'TRUE')->lists('email')->toArray(); if ($volunteer == null) { $status = ["error"]; return response()->json(compact('status')); } else { Mail::send('emails.volunteer_registration', compact('volunteer'), function ($message) use($mailingList) { $message->subject('New Volunteer Registration'); $message->bcc($mailingList); }); $status = ["Created successfully"]; return response()->json(compact('status')); } }
public function postReset(Request $request) { $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']); $flag = Staff::where('email', $request->email)->get()->first(); if ($flag->active == 0) { return redirect()->back()->with('message', 'Account is not active!'); } $credentials = $request->only('email', 'password', 'password_confirmation', 'token'); $response = Password::reset($credentials, function ($user, $password) { $this->resetPassword($user, $password); }); switch ($response) { case Password::PASSWORD_RESET: return redirect($this->redirectPath())->with('status', trans($response)); default: return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['title'] = 'Invoices'; $data['invoice_menu'] = 1; $staff = Staff::find(\Session::get('user')->staff_id); foreach ($staff->classes as $class) { $classes[$class->id] = $class->name; } //create array to hole school session starting 10 yrs from current date $sessions = ['Select Session']; for ($i = intval(date('Y')) - 10; $i < intval(date('Y')) + 15; $i++) { $session = $i . '-' . ($i + 1); $sessions[$session] = $session; } $data['sessions'] = $sessions; $data['terms'] = ['Select Term', 1, 2, 3]; $data['classes'] = studentClass::lists('name', 'id')->prepend('Select Class'); $data['fee_elements'] = FeeElement::where('status_id', 1)->get(); return view('billing.invoices.class_invoices', $data); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Requests\CreateTeachersRequest $request) { $username = $request->username; $password = $request->password; $firstname = $request->firstname; $lastname = $request->lastname; $phone = $request->phone; $gender = $request->gender; $email = $request->email; $district = $request->district; $dob = $request->dob; $date_joined = $request->date_joined; $description = $request->description; $user = User::create(array('username' => $username, 'password' => Hash::make($password))); $staff = Staff::create(array('user_id' => $user->id, 'firstname' => $firstname, 'lastname' => $lastname, 'phone' => $phone, 'gender' => $gender, 'dob' => $dob, 'district' => $district, 'date_joined' => $date_joined, 'email' => $email, 'description' => $description)); if ($staff) { $user->staff()->associate($staff); //assign the subjects to the teacher $staff->subjects()->sync($request->subjects); return redirect()->route('create_teacher')->with('message', 'Teacher added successfully'); } else { return redirect()->route('create_teacher')->with('error-message', 'Error adding the Staff member'); } }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $this->validate($request, ['service_date' => 'required', 'regular_count' => 'required', 'visitor_count' => 'required']); //Store method is responsible for throwing data into database, and redirect to somewhere else $input = $request->all(); Attendance::edit_attendance($input, $id); $attendance = Attendance::get_attendance($id); $congregation = Congregation::get_congregation($attendance->congregation_id); $staff = Staff::get_staff($attendance->staff_id); $message = 'Attendance for "' . $congregation->name . '" has been updated successfully.'; return view('attendances.show', compact('attendance', 'message', 'congregation', 'staff')); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return Staff::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Staff $staff) { $staff->delete(); return redirect()->route('admin.staffs.index'); }
public function update($id, RegisterStaff $request) { $staff = Staff::findOrFail($id); $staff->update($request->all()); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if (Gate::allows('check-leader')) { $staff = Staff::find($id)->level->role; if ($staff->name != "Developer") { return redirect()->route('admin.staff.index')->with('message', 'Access is denied'); } } if (Gate::allows('check-admin')) { $staff = Staff::find($id)->level->role; if ($staff->name == "Developer") { return redirect()->route('admin.staff.index')->with('message', 'Access is denied'); } } if (Gate::allows('check-developer')) { return redirect()->route('admin.department.index')->with('message', 'Access is denied'); } // if staff belongsto one team $findStaff = StaffTeam::where('staff_id', $id)->get()->toArray(); if (!empty($findStaff)) { return redirect()->route('admin.staff.index')->with('message', 'The staff belongto team !'); } $staff = Staff::find($id); $staff->delete(); // delete staff in review $staffReview = Review::where('reviewer_id', $id)->delete(); $staffReview = Review::where('staff_id', $id)->delete(); // delete staff in staff_team $staffReview = StaffTeam::where('staff_id', $id)->delete(); return redirect()->route('admin.staff.index')->with('message', 'Delete staff complete !'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if (Gate::allows('check-leader')) { $staff = Staff::find($id)->level->role; if ($staff->name != "Developer") { return redirect()->route('admin.staff.index')->with('message', 'Access is denied'); } } if (Gate::allows('check-admin')) { $staff = Staff::find($id)->level->role; if ($staff->name == "Developer") { return redirect()->route('admin.staff.index')->with('message', 'Access is denied'); } } if (Gate::allows('check-developer')) { return redirect()->route('admin.department.index')->with('message', 'Access is denied'); } $staff = Staff::find($id); $staff->delete(); return redirect()->route('admin.staff.index')->with('message', 'Delete staff complete !'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // dd($request); //get user u ant to update $user = \Sentinel::findById($id); //get the persons details $staff = Staff::find($request->user); $data = $request->except('_token'); $rules = ['password' => 'min:4|required']; $validator = \Validator::make($data, $rules); if ($validator->passes()) { //array to hold final permission values $array_of_permissions = Helper::prepPermissions($request->exempt_permission, 'false'); $credentials = ['email' => $staff->email, 'password' => $request->password, 'permissions' => $array_of_permissions, 'staff_id' => $staff->id, 'first_name' => $staff->fname, 'last_name' => $staff->lname]; //update user $user = \Sentinel::update($user, $credentials); //get the id(s) of the current roles of this user in an array $current_roles = array(); foreach ($user->roles as $value) { $current_roles[] = $value->id; } //compute role(s) to add $add_roles = array_diff($request->assign_roles, $current_roles); //compute role(s) to delete $delete_roles = array_diff($current_roles, $request->assign_roles); //update user role(s) $user = \Sentinel::findById($user->id); //add ne role(s) foreach ($add_roles as $role_id) { $role = \Sentinel::findRoleById($role_id); $role->users()->attach($user); } //delete role(s), if any foreach ($delete_roles as $role_id) { \DB::table('role_users')->where('role_id', $role_id)->where('user_id', $user->id)->delete(); } return \Redirect::to('settings/users/create'); } else { return \Redirect::back()->withInput()->withErrors($validator); } }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $slug) { // Validation $this->validate($request, ['first_name' => 'required|min:2|max:20', 'last_name' => 'required|min:2|max:30', 'age' => 'required|integer|between:0,130', 'profile_image' => 'image|between:0,2000']); // Find the user or staff member to edit $staffMember = Staff::where('slug', $slug)->firstOrFail(); $staffMember->first_name = $request->first_name; $staffMember->last_name = $request->last_name; $staffMember->age = $request->age; // Insert a slug into the request $staffMember->slug = str_slug($request->first_name . ' ' . $request->last_name); // If the user provided a new image if ($request->hasFile('profile_image')) { // Generare a new file name $fileExtension = $request->file('profile_image')->getClientOriginalExtension(); $fileName = 'staff-' . uniqid() . '.' . $fileExtension; $request->file('profile_image')->move('img/staff', $fileName); \Image::make('img/staff/' . $fileName)->resize(240, null, function ($constraint) { $constraint->aspectRatio(); })->save('img/staff/' . $fileName); // Delete the old image \File::Delete('img/staff/' . $staffMember->profile_image); // Tell database $staffMember->profile_image = $fileName; } // Update the database $staffMember->save(); return redirect('about/' . $staffMember->slug); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Staff $staff) { if ($staff->deleted_at !== null) { abort(410); } $staff->delete(); return Redirect::route('staff.index')->with('message', 'Staff deleted'); }