jeudi 1 décembre 2016

How to copmpaire table colum values with Auth::user->id in Laravel

My problem is this I am using following codes to access users to the system in different roles.

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);
        }

In My permission table there is collaborator_id and it is same to users table user id. I need validate (compaire) collaborator_id with logged user Auth::user->id. in following scripts.

if (Permission::where('status', 1)->where('project_id', $id)->exists())

how can do it? Grete help.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gSOsvh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire