0
我的問題是這個我正在使用下面的代碼來訪問不同角色的系統用戶。如何將表列值與Auth :: user-> id在Laravel中進行比較
public function show($id)
{
if (Permission::where('status', 1)->where('project_id', $id)->exists()) {
// if((Permission::where('status', '=', '1')->first()) && (Permission::where('project_id','=',$id)->first())){
$project = Project::find($id);
$tasks = $this->getTasks($id);
$files = $this->getFiles($id);
$comments = $this->getComments($id);
$collaborators = $this->getCollaborators($id);
$permissions = $this->getPermissions($id);
returnview('collaborators.show')->withProject($project)->withTasks($tasks)->withFiles($files)->withComments($comments)->withCollaborators($collaborators);
}
else if
//return('hi');
(Permission::where('status', 2)->where('project_id', $id)->exists()) {
$project = Project::find($id);
$tasks = $this->getTasks($id);
$files = $this->getFiles($id);
$comments = $this->getComments($id);
$collaborators = $this->getCollaborators($id);
$permissions = $this->getPermissions($id);
return view('collaborators.manager')->withProject($project)->withTasks($tasks)->withFiles($files)->withComments($comments)->withCollaborators($collaborators);
}
在我的權限表有collaborator_id,這是相同的用戶表的用戶ID。我需要使用登錄用戶Auth::user->id
驗證(比較)collaborator_id。在以下腳本中。
if (Permission::where('status', 1)->where('project_id', $id)->exists())
怎麼能行呢?
是的,它正在工作 – Fernando