/** * Run the database seeds. * * @return void */ public function run() { User::truncate(); Staff::truncate(); Student::truncate(); StudentNumber::truncate(); StaffNumber::truncate(); $user = ['first_name' => 'Jose Antonio', 'last_name' => 'Sinadinse', 'fullname' => '', 'password' => \Hash::make('password'), 'email' => '*****@*****.**', 'address' => 'Pretoria', 'cellnumber' => '000000000', 'user_type_id' => 1, 'state_id' => 1]; if (StaffNumber::all()->count() == 0) { $stfnum = StaffNumber::create(["number" => 2000, "date" => date("Y-m-d")]); } else { $lateststfnum = StaffNumber::all()->last(); $stfnum = StaffNumber::create(["number" => $lateststfnum->number + 1, "date" => date("Y-m-d")]); } $staff = Staff::create(['staff_number' => $stfnum->number]); $user = $staff->user()->create($user); $user->addPermission('admin'); for ($i = 3; $i < 20; $i++) { $user = ['first_name' => 'Name' . $i, 'last_name' => 'Surname' . $i, 'fullname' => '', 'password' => \Hash::make('aleluia'), 'email' => 'josebarros' . $i . '@hotmail.com', 'address' => 'Pretoria', 'cellnumber' => '00000000' . $i, 'user_type_id' => 3, 'state_id' => 1]; if (StudentNumber::all()->count() == 0) { $stdnum = StudentNumber::create(["number" => 200000000, "date" => date("Y-m-d")]); } else { $lateststdnum = StudentNumber::all()->last(); $stdnum = StudentNumber::create(["number" => $lateststdnum->number + 1, "date" => date("Y-m-d")]); } $student = Student::create(['student_number' => $stdnum->number, "university_id" => 1, "faculty_id" => '', "department_id" => '', "course_id" => '']); $user = $student->user()->create($user); $user->addPermission('student'); } }
public static function delete($id) { $staff = Staff::find($id); if (!is_null($staff->first())) { return $staff->delete(); } else { return false; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Staff::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['staff_id' => $this->staff_id, 'position_id' => $this->position_id, 'department_id' => $this->department_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Staff::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'fechaNacimiento' => $this->fechaNacimiento]); $query->andFilterWhere(['like', 'dpto_nombre', $this->dpto_nombre])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellido1', $this->apellido1])->andFilterWhere(['like', 'apellido2', $this->apellido2])->andFilterWhere(['like', 'rut', $this->rut])->andFilterWhere(['like', 'cargo', $this->cargo])->andFilterWhere(['like', 'rol', $this->rol])->andFilterWhere(['like', 'domicilio', $this->domicilio])->andFilterWhere(['like', 'telefono', $this->telefono])->andFilterWhere(['like', 'correo', $this->correo]); return $dataProvider; }
/** * Store a newly created resource in storage. * * @return Response */ public function store(UsersRequest $request) { $user = ['first_name' => $request->input('first_name'), 'last_name' => $request->input('last_name'), 'fullname' => '', 'password' => '0000', 'email' => $request->input('email'), 'address' => $request->input('address'), 'cellnumber' => $request->input('cellnumber'), 'user_type_id' => $request->input('user_type_id'), 'state_id' => 1]; if ($request->input("user_type_id") === "1") { $student = Staff::create(['staff_number' => '00000']); $user = $student->user()->create($user); $user->makeEmployee('admin'); } else { if ($request->input("user_type_id") === "2") { $student = Staff::create(['staff_number' => '00000']); $user = $student->user()->create($user); $user->makeEmployee('lecturer'); } else { $student = Student::create(['student_number' => '00000']); $user = $student->user()->create($user); $user->makeEmployee('student'); } } return redirect("/users"); }
public function GetStaffName($id) { $name = ""; $model = new Staff(); $model = Staff::find()->where(['formalemail' => $id])->one(); $name = $model->name; return $name; }
/** * @return \yii\db\ActiveQuery */ public function getStaff() { return $this->hasMany(Staff::className(), ['dpto_nombre' => 'nombre']); }
/** * @return \yii\db\ActiveQuery */ public function getStaff() { return $this->hasMany(Staff::className(), ['department_id' => 'department_id']); }
/** * * @return \yii\db\ActiveQuery */ public function getOwner0() { return $this->hasOne(Staff::className(), ['formalemail' => 'owner']); }
/** * Finds the Staff model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Staff the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Staff::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getReqBy() { return $this->hasOne(Staff::className(), ['staff_id' => 'req_by']); }
public function getStudentNumberAttribute() { if ($this->userable_type === "App\\Models\\Student") { $student = \App\Models\Student::findOrFail($this->userable_id); return $student->student_number; } $staff = \App\Models\Staff::findOrFail($this->userable_id); return $staff->staff_number; }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return DB::transaction(function () use($data) { $data['status'] = "WAITING_APPROVAL"; $data['password'] = bcrypt($data['password']); $user = new User(); $user = User::create($data); if (isset($data['avatar'])) { $imageName = time() . '.' . $data['avatar']->getClientOriginalExtension(); $location = 'uploads/avatar/' . str_slug($user->name) . '/'; $data['avatar']->move($location, $imageName); $user->avatar = url($location . $imageName); } else { if ($data['gender'] == "F") { $user->avatar = url('uploads/avatar/defaultLady.jpg'); } else { $user->avatar = url('uploads/avatar/defaultMale.jpg'); } } $user->save(); $data['user_id'] = $user->id; switch ($data['UsertypeName']) { case 'Student': Student::create($data); break; case 'Parent': ParentModel::create($data); break; case 'Staff': Staff::create($data); break; default: Foundation::create($data); break; } return $user; }); }
public function updateView($id) { $staff = Staff::find($id); $data = ['page_title' => 'Staff', 'panel_title' => 'Form Edit', 'form_url' => '/dash/setting/staff/update', 'form_status' => 'edit', 'staff' => $staff]; return View::make('staff.form', $data); }
public function destroy($id) { Staff::find($id)->delete(); return redirect('staffs'); }
use yii\helpers\Html; //use yii\widgets\ActiveForm; use kartik\widgets\ActiveForm; use kartik\widgets\DatePicker; use app\models\RequestType; use yii\helpers\ArrayHelper; use app\models\Staff; /* @var $this yii\web\View */ /* @var $model app\models\RequestDic */ /* @var $form yii\widgets\ActiveForm */ ?> <?php $RequestType = RequestType::find()->all(); $arraytype = ArrayHelper::map($RequestType, 'type_id', 'request_name'); $Staff = Staff::find()->all(); $arrayStaff = ArrayHelper::map($Staff, 'staff_id', 'name'); if (isset($erros)) { echo Alert::widget(['options' => ['class' => 'alert-info'], 'body' => $erros]); } ?> <div class="request-dic-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'req_type_id')->dropDownList($arraytype, ['prompt' => '--Select--']); ?>
/** * @return \yii\db\ActiveQuery */ public function getStaff() { return $this->hasOne(Staff::className(), ['formalemail' => 'staffID']); }
/** * @return \yii\db\ActiveQuery */ public function getStaff() { return $this->hasMany(Staff::className(), ['position_id' => 'positio_id']); }