[
'class' => AccessControl::className(),
'rules' => [
[
//'actions' => ['cabinet','change-password', 'bookmarks', 'projects'],
'allow' => true,
'roles' => [ '@' ],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'team-delete' => [ 'POST' ],
'vacancy-delete' => [ 'POST' ],
'portfolio-delete' => [ 'POST' ],
'projects-delete' => [ 'POST' ],
'blog-delete' => [ 'POST' ],
],
],
];
}
/**
* Page of additional skills, consist:
* * working with programs;
* * education;
* * own developments and patents;
* * courses and trainings;
* @return string
*/
public function actionAddSkills()
{
$user = \Yii::$app->user->identity;
if(!empty( \Yii::$app->request->post() )) {
Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
}
return $this->render('add-skills', [ 'user' => $user ]);
}
/**
* Page of blog grid view
* @return string
*/
public function actionBlog()
{
$searchModel = new BlogSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('blog', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Page of creating one record of blog.
* @return string|\yii\web\Response Page html / Redirect
*/
public function actionBlogCreate()
{
$blog = new Blog();
$post = \Yii::$app->request->post();
if($blog->load($post) && $blog->save()) {
return $this->redirect([
'blog',
]);
} else {
return $this->render('_blog_form', [ 'blog' => $blog ]);
}
}
/**
* Page of editting one User's record of blog.
*
* @param integer $id ID of User's record
*
* @return string|\yii\web\Response Page html / Redirect
* @throws NotFoundHttpException if not found or someone else's post
*/
public function actionBlogUpdate($id)
{
$user = \Yii::$app->user->identity;
$blog = $user->getBlog()
->where([ 'blog_id' => $id ])
->one();
if(!$blog instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$post = \Yii::$app->request->post();
if($blog->load($post) && $blog->save()) {
return $this->redirect('blog');
} else {
return $this->render('_blog_form', [ 'blog' => $blog ]);
}
}
/**
* Delete User's blog record
*
* @param $id ID of User's record
*
* @return \yii\web\Response Redirect
* @throws NotFoundHttpException
*/
public function actionBlogDelete($id)
{
$user = \Yii::$app->user->identity;
$blog = $user->getBlog()
->where([ 'blog_id' => $id ])
->one();
if(!$blog instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$blog->delete();
return $this->redirect('blog');
}
/**
* Page of contacts. Consist:
* * phones;
* * social pages;
* * sites;
* @return string page html
*/
public function actionContacts()
{
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
if(!empty( \Yii::$app->request->post() )) {
if(!empty( Yii::$app->request->post('Fields') )) {
Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
}
$user_info->load(\Yii::$app->request->post());
$user_info->save();
}
return $this->render('contacts', [ 'user_info' => $user_info ]);
}
/**
* Page of description. Consist of information about User.
* @return string page html
*/
public function actionDescription()
{
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$user_info->load($post);
$user_info->save();
}
return $this->render('description', [ 'user_info' => $user_info ]);
}
/**
* Page of seniority. Consist:
* * current job;
* * year of the beginning of designing
* * previous jobs
* @return string page html
*/
public function actionEmployment()
{
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$user_info->load($post);
$user_info->save();
$job = [ ];
for($i = 0; $i < count($post[ 'Job' ]); $i++) {
$job[ $i ] = new Job([
'user_id' => \Yii::$app->user->getId(),
'current' => 0,
]);
}
if(Job::loadMultiple($job, $post)) {
$job[ 0 ]->current = 1;
if(Job::validateMultiple($job)) {
Job::deleteAll([ 'user_id' => \Yii::$app->user->getId() ]);
foreach($job as $onejob) {
$onejob->save(false);
}
}
}
} else {
$job = $user->getJobs()
->orderBy([ 'current' => SORT_DESC ])
->all();
if(empty( $job )) {
$job[] = new Job([
'user_id' => \Yii::$app->user->getId(),
'current' => 0,
]);
}
if(!$job[ 0 ]->current) {
array_unshift($job, new Job([
'user_id' => \Yii::$app->user->getId(),
'current' => 1,
]));
}
}
return $this->render('employment', [
'job' => $job,
'user_info' => $user_info,
]);
}
/**
* Page of User's image galleries
* @return string
*/
public function actionGallery()
{
$searchModel = new GallerySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('gallery', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Page of User's videos
* @return string
*/
public function actionGalleryVideo()
{
$user = \Yii::$app->user->identity;
$video = Fields::getData($user->id, Gallery::className(), 'youtube');
if(!empty( Yii::$app->request->post('Fields') )) {
Fields::saveFieldVideoData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru');
}
return $this->render('gallery-video', [
'video' => $video,
'user' => $user,
]);
}
/**
* Page of creating a photo gallery
* @return string|\yii\web\Response
*/
public function actionGalleryCreate()
{
$gallery = new Gallery();
$user = \Yii::$app->user->identity;
$post = \Yii::$app->request->post();
if($gallery->load($post) && $gallery->save()) {
return $this->redirect([
'gallery',
]);
} else {
return $this->render('_gallery_form', [
'gallery' => $gallery,
'user' => $user,
]);
}
}
/**
* Page of updating existing photo gallery
*
* @param $id ID of Gallery
*
* @return string|\yii\web\Response
*/
public function actionGalleryUpdate($id)
{
$user = \Yii::$app->user->identity;
$gallery = $user->getGalleries()
->where([ 'gallery_id' => $id ])
->one();
$post = \Yii::$app->request->post();
if($gallery->load($post) && $gallery->save()) {
return $this->redirect([
'gallery',
]);
} else {
return $this->render('_gallery_form', [
'gallery' => $gallery,
'user' => $user,
]);
}
}
/**
* Page of deleting existing photo gallery
*
* @param $id ID of Gallery
*
* @throws \Exception
*/
public function actionGalleryDelete($id)
{
Gallery::findOne($id)
->delete();
$this->redirect('gallery');
}
/**
* Page of credentials. Consist:
*
* -
* Company info:
*
* - Company name
* - Employees count
* - Street
* - House
*
*
* -
* User info:
*
* - User name
* - User surname
* - Email
*
*
* -
* Common info:
*
* - Status (free/busy)
* - City
* - Avatar
* - Cover
* - Membership
*
*
*
* @return string page html
*/
public function actionGeneral()
{
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
$company_info = $user->companyInfo;
$user = \Yii::$app->user->identity;
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => $user->id ]);
}
if(empty( $company_info )) {
$company_info = new CompanyInfo([ 'user_id' => $user->id ]);
}
$post = \Yii::$app->request->post();
if(!empty( $post )) {
if($user_info->load($post)) {
$user_info->save();
}
if($company_info->load($post)) {
$company_info->save();
}
if($user->load($post) && $user->save()) {
\Yii::$app->session->setFlash('userinfoupdate', 'Информация успешно обновлена');
} else {
\Yii::$app->session->setFlash('userinfoupdate', 'Ошибка обновления. Проверьте форму');
}
}
return $this->render('general', [
'user_info' => $user_info,
'user' => $user,
'company_info' => $company_info,
]);
}
/**
* Renders form via ajax, using lastindex.
*
* @param integer $lastindex Last index of form input of current type
*
* @return string
*/
public function actionGetForm($lastindex)
{
return $this->renderAjax('_job_form', [ 'index' => $lastindex + 1 ]);
}
/**
* Page of User's portfolio
* @return string
*/
public function actionPortfolio()
{
$searchModel = new PortfolioSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->pagination->pageSize = 5;
return $this->render('portfolio', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Page of creating User's portfolio records.
* @return string|\yii\web\Response
*/
public function actionPortfolioCreate()
{
$user = \Yii::$app->user->identity;
$portfolio = new Portfolio();
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$galleries = $user->getGalleries()
->select([
'name',
'gallery_id',
])
->asArray()
->indexBy('gallery_id')
->column();
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$portfolio->load($post);
$portfolio->validate();
if(!$portfolio->hasErrors()) {
$portfolio->save();
$portfolio->unlinkAll('specializations', true);
foreach($portfolio->specializationInput as $one_specialization) {
$portfolio->link('specializations', Specialization::findOne($one_specialization));
}
return $this->redirect('portfolio');
}
}
return $this->render('_portfolio_form', [
'portfolio' => $portfolio,
'specializations' => $specializations,
'galleries' => $galleries,
]);
}
/**
* Page of updating User's portfolio record.
*
* @param integer $id ID of User's portfolio record
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException if record not found
*/
public function actionPortfolioUpdate($id)
{
$user = \Yii::$app->user->identity;
$portfolio = $user->getPortfolios()
->where([ 'portfolio_id' => $id ])
->one();
$galleries = $user->getGalleries()
->select([
'name',
'gallery_id',
])
->asArray()
->indexBy('gallery_id')
->column();
if(!$portfolio instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$portfolio->load($post);
$portfolio->validate();
if(!$portfolio->hasErrors()) {
$portfolio->save();
$portfolio->unlinkAll('specializations', true);
foreach($portfolio->specializationInput as $one_specialization) {
$portfolio->link('specializations', Specialization::findOne($one_specialization));
}
return $this->redirect('portfolio');
}
}
return $this->render('_portfolio_form', [
'portfolio' => $portfolio,
'specializations' => $specializations,
'galleries' => $galleries,
]);
}
/**
* Page of deleting User's portfolio record.
*
* @param integer $id ID of User's portfolio record
*
* @throws NotFoundHttpException
* @throws \Exception if record not found
*/
public function actionPortfolioDelete($id)
{
$user = \Yii::$app->user->identity;
$portfolio = $user->getPortfolios()
->where([ 'portfolio_id' => $id ])
->one();
if(!$portfolio instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$portfolio->delete();
$this->redirect('portfolio');
}
/**
* Page of User's projects.
* @return string
*/
public function actionProjects()
{
$searchModel = new ProjectSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('projects', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Page of creating User's project.
* @return string|\yii\web\Response
*/
public function actionProjectsCreate()
{
$project = new Project();
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
$projects = Project::find()
->select([
'name',
'project_id',
])
->where([ 'user_id' => \Yii::$app->user->getId() ])
->indexBy('project_id')
->asArray()
->column();
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$project->load($post);
$project->validate();
if(!$project->hasErrors()) {
$date_end = new \DateTime();
switch($post[ 'Project' ][ 'date_end' ]) {
case 2:
$date_end->modify('+14 day');
break;
case 3:
$date_end->modify('+30 day');
break;
default:
$date_end->modify('+7 day');
};
$project->date_end = \Yii::$app->formatter->asDate($date_end->getTimestamp(), 'short');
$project->save();
$project->unlinkAll('specializations', true);
foreach($project->specializationInput as $one_specialization) {
$project->link('specializations', Specialization::findOne($one_specialization));
}
$project->unlinkAll('payments', true);
foreach($project->paymentInput as $one_payment) {
$project->link('payments', Payment::findOne($one_payment));
}
return $this->redirect([
'projects',
]);
}
}
return $this->render('_projects_form', [
'project' => $project,
'specializations' => $specializations,
'payment' => $payment,
'projects' => $projects,
]);
}
/**
* Page of updating User's project.
*
* @param integer $id ID of User's project
*
* @return string
* @throws NotFoundHttpException if record not found
*/
public function actionProjectsUpdate($id)
{
$user = \Yii::$app->user->identity;
$project = $user->getProjects()
->where([ 'project_id' => $id ])
->one();
if(!$project instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
$projects = $user->getProjects()
->select([
'name',
'project_id',
])
->andWhere([
'not',
[ 'project_id' => $project->project_id ],
])
->indexBy('project_id')
->asArray()
->column();
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$project->load($post);
$project->validate();
if(!$project->hasErrors()) {
$date_end = new \DateTime();
switch($post[ 'Project' ][ 'date_end' ]) {
case 2:
$date_end->modify('+14 day');
break;
case 3:
$date_end->modify('+30 day');
break;
default:
$date_end->modify('+7 day');
};
$project->date_end = \Yii::$app->formatter->asDate($date_end->getTimestamp(), 'short');
$project->save();
$project->unlinkAll('specializations', true);
foreach($project->specializationInput as $one_specialization) {
$project->link('specializations', Specialization::findOne($one_specialization));
}
$project->unlinkAll('payments', true);
foreach($project->paymentInput as $one_payment) {
$project->link('payments', Payment::findOne($one_payment));
}
return $this->redirect([ 'projects' ]);
}
}
return $this->render('_projects_form', [
'project' => $project,
'specializations' => $specializations,
'payment' => $payment,
'projects' => $projects,
]);
}
/**
* Page of deleting User's project
*
* @param integer $id ID of User's project
*
* @throws NotFoundHttpException
* @throws \Exception
*/
public function actionProjectsDelete($id)
{
$user = \Yii::$app->user->identity;
$project = $user->getProjects()
->where([ 'project_id' => $id ])
->one();
if(!$project instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$project->delete();
$this->redirect('projects');
}
/**
* Page of editting User's service info. Consist of:
* * cost of work;
* * service specializations;
* * work geography;
* * work guarantee;
* * work on contract;
* * providing estimates;
* * purchase of materials;
* * delivery of materials;
* * minimal prepayment;
* * payment types;
* @return string
*/
public function actionService()
{
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
$currencies = Currency::getCurrencyDropdown();
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$user_info->load($post);
$user_info->validate();
if(!$user_info->hasErrors()) {
$user_info->save();
$user->load($post);
$user->unlinkAll('specializations', true);
foreach($user->specializationInput as $one_specialization) {
$user->link('specializations', Specialization::findOne($one_specialization));
}
$user->unlinkAll('payments', true);
foreach($user->paymentInput as $one_payment) {
$user->link('payments', Payment::findOne($one_payment));
}
}
}
return $this->render('service', [
'user' => $user,
'user_info' => $user_info,
'specializations' => $specializations,
'payment' => $payment,
'currencies' => $currencies,
]);
}
/**
* Page of account setting. Consist of:
* * changing password;
* @return string
*/
public function actionSetting()
{
$user = \Yii::$app->user->identity;
$post = \Yii::$app->request->post('User');
if(!empty( $post )) {
if(empty( $post[ 'new_password' ] )) {
$user->addError('new_password', 'Введите новый пароль');
} else {
$user->new_password = $post[ 'new_password' ];
}
if(empty( $post[ 'old_password' ] )) {
$user->addError('old_password', 'Введите новый пароль');
} else {
$user->old_password = $post[ 'old_password' ];
}
if(empty( $post[ 'password_reply' ] ) || $post[ 'password_reply' ] !== $post[ 'new_password' ]) {
$user->addError('password_reply', 'Неправильный повтор пароля');
} else {
$user->password_reply = $post[ 'password_reply' ];
}
if(!$user->hasErrors()) {
if($user->validatePassword($user->old_password)) {
$user->setPassword($user->new_password);
$user->generateAuthKey();
if($user->save()) {
\Yii::$app->session->setFlash('passwordupdate', 'Пароль успешно обновлен');
}
} else {
$user->addError('old_password', 'Неправильный старый пароль');
}
}
}
return $this->render('setting', [ 'user' => $user ]);
}
/**
* Page of company's team
* @return string
*/
public function actionTeam()
{
$searchModel = new TeamSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$departments = Department::find()
->select([
'name',
'department_id',
])
->indexBy('department_id')
->asArray()
->column();
return $this->render('team', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'departments' => $departments,
]);
}
/**
* Page of creating company's team member
* @return string|\yii\web\Response
*/
public function actionTeamCreate()
{
$team = new Team();
$department = Department::find()
->select([
'name',
'department_id',
])
->indexBy('department_id')
->asArray()
->column();
$country = Country::find()
->select([ 'country_name' ])
->indexBy('country_name')
->asArray()
->column();
$post = \Yii::$app->request->post();
if($team->load($post) && $team->save()) {
return $this->redirect([
'team',
]);
} else {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
}
}
/**
* Page of updating company's team member info.
*
* @param integer $id ID of company's team member
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionTeamUpdate($id)
{
$user = \Yii::$app->user->identity;
$team = $user->getTeams()
->where([ 'team_id' => $id ])
->one();
if(!$team instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$department = Department::find()
->select([
'name',
'department_id',
])
->indexBy('department_id')
->asArray()
->column();
$country = Country::find()
->select([ 'country_name' ])
->indexBy('country_name')
->asArray()
->column();
$post = \Yii::$app->request->post();
if($team->load($post) && $team->save()) {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
// return $this->redirect([
// 'team',
// ]);
} else {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
}
}
/**
* Page of deleting company's team member.
*
* @param integer $id ID of company's team member
*
* @throws NotFoundHttpException
* @throws \Exception
*/
public function actionTeamDelete($id)
{
$user = \Yii::$app->user->identity;
$team = $user->getTeams()
->where([ 'team_id' => $id ])
->one();
if(!$team instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$team->delete();
$this->redirect('team');
}
/**
* Page of company's vacancies
* @return string
*/
public function actionVacancy()
{
$searchModel = new VacancySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('vacancy', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Page of creating company's vacancies.
* @return string|\yii\web\Response
*/
public function actionVacancyCreate()
{
$vacancy = new Vacancy();
$employment = Employment::find()
->select([
'name',
'employment_id',
])
->indexBy('employment_id')
->asArray()
->column();
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$currencies = Currency::getCurrencyDropdown();
$user = \Yii::$app->user->identity;
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$vacancy->load($post);
$vacancy->validate();
if(empty( $vacancy->specializationInput )) {
$vacancy->addError('specializationInput');
}
if(!$vacancy->hasErrors()) {
$vacancy->save();
Fields::saveFieldData(Yii::$app->request->post('Fields'), $vacancy->vacancy_id, Vacancy::className(), 'ru');
$vacancy->unlinkAll('employments', true);
foreach($vacancy->employmentInput as $one_employment) {
$vacancy->link('employments', Employment::findOne($one_employment));
}
$vacancy->unlinkAll('specializations', true);
foreach($vacancy->specializationInput as $one_specialization) {
$vacancy->link('specializations', Specialization::findOne($one_specialization));
}
return $this->redirect([
'vacancy',
]);
}
}
return $this->render('_vacancy_form', [
'vacancy' => $vacancy,
'employment' => $employment,
'currencies' => $currencies,
'specializations' => $specializations,
'user' => $user,
]);
}
/**
* Page of updating company's vacancy.
*
* @param integer $id ID of company's vacancy.
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionVacancyUpdate($id)
{
$user = \Yii::$app->user->identity;
$vacancy = $user->getVacancies()
->where([ 'vacancy_id' => $id ])
->one();
if(!$vacancy instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$employment = Employment::find()
->select([
'name',
'employment_id',
])
->indexBy('employment_id')
->asArray()
->column();
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$user = \Yii::$app->user->identity;
$currencies = Currency::getCurrencyDropdown();
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$vacancy->load($post);
$vacancy->validate();
if(!$vacancy->hasErrors()) {
$vacancy->save();
Fields::saveFieldData(Yii::$app->request->post('Fields'), $vacancy->vacancy_id, Vacancy::className(), 'ru');
$vacancy->unlinkAll('employments', true);
foreach($vacancy->employmentInput as $one_employment) {
$vacancy->link('employments', Employment::findOne($one_employment));
}
$vacancy->unlinkAll('specializations', true);
foreach($vacancy->specializationInput as $one_specialization) {
$vacancy->link('specializations', Specialization::findOne($one_specialization));
}
return $this->redirect([
'vacancy',
]);
}
}
return $this->render('_vacancy_form', [
'vacancy' => $vacancy,
'employment' => $employment,
'currencies' => $currencies,
'specializations' => $specializations,
'user' => $user,
]);
}
/**
* Page of deleting company's vacancy.
*
* @param integer $id ID of company's vacancy
*
* @throws NotFoundHttpException
* @throws \Exception
*/
public function actionVacancyDelete($id)
{
$user = \Yii::$app->user->identity;
$vacancy = $user->getVacancies()
->where([ 'vacancy_id' => $id ])
->one();
if(!$vacancy instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$vacancy->delete();
$this->redirect('vacancy');
}
/**
* Used to find model of User and throws exception if not found.
*
* @param integer $id ID of User
*
* @return User if User with particular ID found
* @throws NotFoundHttpException if User with particular ID not found
*/
protected function findUser($id)
{
if($model = User::findOne([ "id" => $id ])) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}