Skip to content

Instantly share code, notes, and snippets.

@craig-davis
Last active April 13, 2017 12:32
Show Gist options
  • Save craig-davis/d77b084f8618f0ffa34079a5ebaaf9d5 to your computer and use it in GitHub Desktop.
Save craig-davis/d77b084f8618f0ffa34079a5ebaaf9d5 to your computer and use it in GitHub Desktop.
<?php
class Post
{
public function canEdit(User $user) : bool
{
$canEdit = false;
if (($user->getRole() == 3 && $this->getEditorId() == $user->getId()) || $user->getRole() > 5 || ($this->getAuthorId() == $user->getId() && $this->created_at < time() — 2592000)) {
$canEdit = true;
}
return $canEdit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment