所以我有这个问题,我无法通过它,我试图获得我用这个视图发送的参数
@if(Auth::user())
<a href="/apply/success/{{$data->VacanciesID}}" class="btn turquoiseButton">Apply</a>
@else
<a href="/careers/{{$data->VacanciesID}}/apply" class="btn turquoiseButton">Apply</a>
@endif
当用户没有登录时,它会将他重定向到注册表单并发送“空缺ID”&#39;到注册表格,所以它在网址中,但我不能得到刀片的网址参数发送它的形式的动作看起来像这样/职业/ 1 /申请我需要&# 39; 1&#39;
以下是我的登记表格
<form action="/register/" method="POST" class="careersform">
<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />
<h4>User Details</h4>
<hr>
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Username</label>
<input name="EmployeeUsername" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Password</label>
<input name="EmployeePassword" type="text" class="form-control">
</div>
</div>
</div>
<h4>Personal Details</h4>
<hr>
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>First Name</label>
<input name="FName" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Last Name</label>
<input name="LName" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Gender</label>
<select name="Gender" class="form-control">
<option>Male</option>
<option>Female</option>
</select>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Date of Birth</label>
<input name="DOB" type="date" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Marital Status</label>
<select name="MaritalStatus" class="form-control">
<option>Single</option>
<option>Married</option>
<option>Other</option>
</select>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Country of Nationality</label>
<select name="CountryOfNationality" class="form-control">
<option>Jordan</option>
<option>Other..</option>
</select>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>National ID</label>
<input name="NationID" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Image</label>
<input name="Image" type="file" class="form-control">
</div>
</div>
<div class="form-group col-md-6 col-xs-12">
<img id="ImgUpload" src="/images/avatar.png" alt="Uploaded Image"/>
</div>
</div>
<h4>Education Details</h4>
<hr>
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>School's Name</label>
<input name="SchoolName" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Education Level</label>
<select name='EducationLevel' class="form-control">
<option>High school</option>
<option>Some college</option>
<option>Bachelor's degree</option>
<option>Master's degree</option>
</select>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Major</label>
<input name="EducationMajor" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>GPA</label>
<input name="GBA" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Add Another Education</label>
<input name="education" type="text" class="form-control">
</div>
</div>
</div>
<h4>Experience Details</h4>
<hr>
<div class="row">
<div class="col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Company's Name</label>
<input name="CompanyName" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Job Title</label>
<input name="JobTitle" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Salary</label>
<input name="Salary" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Start date</label>
<input name="StartDate" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>End date</label>
<input name="EndDate" type="text" class="form-control">
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="form-group careersform-group-styled required">
<label>Add Another Experience</label>
<input name="anotherexperience" type="text" class="form-control">
</div>
</div>
</div>
<button type="submit" class="btn turquoiseButton">Submit</button>
</form>
注册路线:
Route::post('register/', 'UsersController@careerportalregister');
控制器:
public function careerportalregister(request $request){
$EmployeeUsername = $request->input('username');
$EmployeePassword = $request->input('password');
$role_id = $request->input('role_id');
$rol = $request->input('roles');
$roles= explode("," ,$rol);
$validator = Validator::make($request->all(), [
'password' => 'required|min:5|confirmed',
'confirm_password' => 'required|min:6|confirmed'
]);
// if ($validator->fails()) {
// return redirect('/user/create')
// ->withErrors($validator)
// ->withInput();
// } else {
$employee = user::create([
'username' => $request->input('EmployeeUsername'),
'password' => bcrypt($request->input('EmployeePassword')),
]);
$Title = $request->input('Title');
$Gender = $request->input('Gender');
$FName = $request->input('FName');
$LName = $request->input('LName');
$DOB = $request->input('DOB');
$MaritalStatus = $request->input('MaritalStatus');
$CountryOfBirth = $request->input('CountryOfBirth');
$CountryOfNationality = $request->input('CountryOfNationality');
$NationID = $request->input('NationID');
$Image = $request->input('Image');
$user_id = $employee->id;
PersonalDetails::CreatePersonalDetails($Title,$Gender ,$FName ,$LName,$DOB,$MaritalStatus,$CountryOfBirth,$CountryOfNationality,$NationID,$Image,$user_id);
$EducationMajor = $request->input('EducationMajor');
$EducationLevel = $request->input('EducationLevel');
$SchoolName = $request->input('SchoolName');
$GBA = $request->input('GBA');;
$user_id = $employee->id;
EducationDetails::CreateEducationDetails($EducationMajor,$EducationLevel ,$SchoolName ,$GBA,$user_id);
$CompanyName = $request->input('CompanyName');
$StartDate = $request->input('StartDate');
$EndDate = $request->input('EndDate');
$Salary = $request->input('Salary');
$JobTitle = $request->input('JobTitle');
$UserID = $employee->id;
ExperienceDetails::CreateExperienceDetails($CompanyName,$StartDate ,$EndDate ,$Salary,$JobTitle,$UserID);
foreach ($roles as $role) {
$count = DB::table('roles')->where('name', $role)->count();
if ($count != 0) {
$s = DB::table('roles')->where('name', $role)->first();
DB::table('role_user')->insert([
'user_id' => $employee->id,
'role_id' => $s->id
]);
}
}
Auth::login($employee, $remember = true);
return Redirect::to('/apply/success/');
}
答案 0 :(得分:1)
在控制器\Request::segment(2)
中
在刀片{{Request::segment(2)}}
2是索引号,可以根据您的需要随意更改。
答案 1 :(得分:0)
我会将id作为可选参数传递给寄存器url。
像这样: Route :: post('register / {vacanciesId?}','UsersController @ careerportalregister');
然后在控制器中获取它并用它做你想做的事。
您也可以将其保存在会话中。
度过愉快的一天,
答案 2 :(得分:0)
假设这是在您的职位空缺页面上,而您遇到的问题是您无法将ID放入网址,您需要遍历每个空缺并设置ID,以便生成链接每个空缺的唯一ID。
另外考虑您有两种不同的方式来提供空缺的详细信息,您需要创建两个Route :: Get'for / apply / success / {{id}}和/ careers / {{id}} / apply
在显示空缺时,我假设您正在从数据库中检索并迭代结果以显示在视图中?您应该编辑帖子并显示它。