我想从表中获取数据。我有两张表,一个测试,另一个是用户,我想将技能与技能进行比较,并显示与技能和技能相匹配的工作。我该怎么办?
public function post( Request $request)
{
Test::create([
'jobtitle'=>$request['jobtitle'],
'company'=>$request['cname'],
'jdesc'=>$request['jdesc'],
'skillneed'=>$request['Skills'],
'duration'=>$request['duration'],
'qualification'=>$request['qualification'],
'experiance'=>$request['experiance'],
'location'=>$request['location'],
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'mobile' => $data['mobile'],
'age' => $data['age'],
'location' => $data['location'],
'resume' => $data['resume'],
'skills' => $data['skills'],
'course' => $data['course'],
'college' => $data['college'],
'role_id'=>$data['role_id'],
]);
}
答案 0 :(得分:0)
您好,您可以使用collection helper contains
$testCollection->contains('skillneed', $user->skills)
返回布尔值
找到所有测试
$filtered = $testCollection->where('skillneed', $user->skills);
返回已过滤的集合
或与DB
$skills = Test::where('skillneed', $user->skills)->get()
答案 1 :(得分:0)
这解决了我的问题
$skill = Auth::user()->skills;
$res = DB::table('tests')->where('skillneed',$skill)->get();
return view('jobs.jobmatching',compact('res'));