/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $input = Input::all(); $this->validate($request, ['Name' => 'required|string', 'PhoneNo' => 'required|digits:11', 'Address' => 'required', 'Email' => 'email']); Staff::create($input); return Redirect::route('staff.index')->with('message', 'Staff created'); }
/** * 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); } }
/** * 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)]); } }
/** * 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)]); } }
/** * Store a new staff. * Responds to requests to POST /staff * * @param \App\Http\Requests\CreateStaffRequest $request * @return Response */ public function store(CreateStaffRequest $request) { $randomString = Str::random(); $staff = Staff::create(['name' => $request->get('name'), 'email' => $request->get('email'), 'password' => bcrypt($randomString), 'is_admin' => $request->has('admin') ? $request->get('admin') : false]); $staff->centres()->attach($request->get('centres')); $email = $staff->email; Mail::send('emails.welcome_staff', compact('staff', 'randomString'), function ($message) use($email) { $message->subject('Your CareGuide Staff account has been created.'); $message->bcc($email); }); return redirect('staff')->with('success', 'Staff is added successfully!'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(createStaffRequest $request) { $staff = Staff::create($request->except('picture')); if ($request->picture->getClientOriginalExtension() == 'jpg') { $imageName = $staff->id . '.' . $request->picture->getClientOriginalExtension(); $request->picture->move(base_path() . '/public/assets/images/staff/', $imageName); session()->flash('flash_message', 'Staff successfully registered.'); session()->flash('flash_message_important', true); return redirect('admin/staff'); } session()->flash('flash_message', 'Only .jpg images are allowed.'); return redirect('admin/staff'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $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' => 'required|image|between:0,2000']); $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); // Extract the form data $input = $request->all(); $input['slug'] = str_slug($request->first_name . ' ' . $request->last_name); $input['profile_image'] = $fileName; $staffMember = Staff::create($input); return redirect('about/' . $staffMember->slug); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $this->validate($request, ['first_name' => 'required|min:2|max:20', 'last_name' => 'required|min:2|max:30', 'age' => 'required|between:0,130|integer', 'profile_image' => 'required|image|between:0,2000']); // Get the files extension $fileExtention = $request->file('profile_image')->getClientOriginalExtension(); // Generate a random name to prevent overwrites $fileName = 'staff-' . uniqid() . '.' . $fileExtention; // Move the file from temp to final $request->file('profile_image')->move('img/staff', $fileName); \Image::make('img/staff/' . $fileName)->resize(240, null, function ($constraint) { $constraint->aspectRatio(); })->save('img/staff/' . $fileName); // Extract the form data $input = $request->all(); // Insert a slug into the request $input['slug'] = str_slug($request->first_name . ' ' . $request->last_name); $input['profile_image'] = $fileName; // Mass assign the form data into the database $staffMember = Staff::create($input); // Redirect to the new staff member by their slug return redirect('about/' . $staffMember->slug); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { // If it fails then it will take you back to the form $this->validate($request, ['first_name' => 'required|min:2|max:20', 'last_name' => 'required|min:2|max:30', 'age' => 'required|between:0,130|integer', 'profile_image' => 'required|image|between:0,2000']); // // LONG WAY OF ADDING A NEW STAFF MEMBER // // Staff() represents the staff model which represents table in the database // $staff = new Staff(); // // Grab the info from the form // $staff->first_name = $request->first_name; // $staff->last_name = $request->last_name; // // $staff->age = $request->age; // // Add to the database // $staff->save(); // Profile image // getClientOriginalExtension grabs the original extension the user used for their image $fileExtension = $request->file('profile_image')->getClientOriginalExtension(); // Generate a new profile image name to avoid duplication // Join the two together ^ ^ $fileName = 'staff-' . uniqid() . '.' . $fileExtension; // - $request->file('profile_image')->move('img/staff', $fileName); // Grabbed the profile image and resized it \Image::make('img/staff/' . $fileName)->resize(240, null, function ($constrait) { $constrait->aspectRatio(); })->save('img/staff/' . $fileName); // Extract the form data $input = $request->all(); // Validation passed! // SHORT WAY OF ADDING A NEW STAFF MEMBER // Insert a slug into the request // str_slug turns whatever comes back from the request to lowercase and add hyphens $input['slug'] = str_slug($request->first_name . ' ' . $request->last_name); $input['profile_image'] = $fileName; $staffMember = Staff::create($input); // Takes user back to staff member's profile page return redirect('about/' . $staffMember->slug); }
/** * 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'); } }
/** * 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'])]); }
/** * Store a newly created resource in storage. * * @param CreateUsersRequest $request * * @return Response */ public function store(CreateUsersRequest $request) { Staff::create($request->all()); return redirect()->route('admin.staffs.index'); }
public function store(RegisterStaff $request) { Staff::create($request->all()); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(StaffRequest $request) { Staff::create($request->all()); Session::flash('message', 'Staff successfully added!'); return redirect('staff'); }