Exemplo n.º 1
0
 /**
  * Roles themselves don't require any fields to create the records - but they do need a record. The name
  * translations are handled within the business rules of the translations.
  *
  * @return static
  */
 public static function create(array $attributes)
 {
     $role = new static();
     $role->default = $attributes['default'];
     $role->raise(new RoleWasCreated($role));
     return $role;
 }
Exemplo n.º 2
0
 /**
  * Create an account switch token
  *
  * @param \Tectonic\Shift\Library\Tokens\TokenGeneratorInterface $tokenGenerator
  *
  * @return static
  */
 public static function createToken(TokenGeneratorInterface $tokenGenerator)
 {
     $token = new static();
     $token->token = $tokenGenerator->generateToken();
     $token->data = $tokenGenerator->encodeData();
     $token->raise(new TokenWasGenerated($token));
     return $token;
 }
Exemplo n.º 3
0
 public static function register($username, $email, $password)
 {
     //in eloquent, when you pass params to instantiate an object
     //you need to pass it through as an array
     $user = new static(compact('username', 'email', 'password'));
     $user->raise(new UserRegistered($user));
     return $user;
 }
Exemplo n.º 4
0
 /**
  * Stores a new blog into database.
  *
  * @param [type] $title       [description]
  * @param [type] $description [description]
  *
  * @return Blog [description]
  */
 public static function post($title, $description)
 {
     $blog = new static();
     $blog->title = $title;
     $blog->description = $description;
     $blog->save();
     $blog->raise(new BlogWasPosted($blog));
     return $blog;
 }
Exemplo n.º 5
0
 /**
  * Register a user
  *
  * @param $username
  * @param $email
  * @param $password
  * @return static
  */
 public static function register($username, $email, $password = false)
 {
     if (!$password) {
         $password = '******';
     }
     $user = new static(compact('username', 'email', 'password'));
     $user->raise(new UserRegistered($user));
     return $user;
 }
Exemplo n.º 6
0
 /**
  * Create a new instance.
  *
  * @param  string  $title
  * @param  \Flarum\Core\Models\User  $user
  * @return static
  */
 public static function start($title, $user)
 {
     $discussion = new static();
     $discussion->title = $title;
     $discussion->start_time = time();
     $discussion->start_user_id = $user->id;
     $discussion->raise(new DiscussionWasStarted($discussion));
     return $discussion;
 }
Exemplo n.º 7
0
 /**
  * Create a game
  *
  * @param $name
  * @param $players
  * @param $private
  * @param $password
  * @internal param $gamename
  * @internal param $email
  * @return static
  */
 public static function createNew($name, $max_players, $private, $password, $user_id)
 {
     if ($private) {
         $game = new static(compact('name', 'max_players', 'private', 'password', 'user_id'));
     } else {
         $game = new static(compact('name', 'max_players', 'user_id'));
     }
     $game->raise(new GameCreated($game));
     return $game;
 }
Exemplo n.º 8
0
 /**
  * Add a new permission object.
  *
  * @param Role $role
  * @param string $resource
  * @param string $action
  * @param Mode $mode
  * @return Permission
  */
 public static function add(Role $role, $resource, $action, Mode $mode)
 {
     $permission = new static();
     $permission->roleId = $role->id;
     $permission->resource = $resource;
     $permission->action = $action;
     $permission->mode = $mode;
     $permission->raise(new PermissionWasAdded($permission));
     return $permission;
 }
Exemplo n.º 9
0
 /**
  * Create a new group.
  *
  * @param string $nameSingular
  * @param string $namePlural
  * @param string $color
  * @param string $icon
  * @return static
  */
 public static function build($nameSingular, $namePlural, $color, $icon)
 {
     $group = new static();
     $group->name_singular = $nameSingular;
     $group->name_plural = $namePlural;
     $group->color = $color;
     $group->icon = $icon;
     $group->raise(new GroupWasCreated($group));
     return $group;
 }
Exemplo n.º 10
0
 /**
  * Register a new user.
  *
  * @param  string  $username
  * @param  string  $email
  * @param  string  $password
  * @return static
  */
 public static function register($username, $email, $password)
 {
     $user = new static();
     $user->username = $username;
     $user->email = $email;
     $user->password = $password;
     $user->join_time = time();
     $user->raise(new UserWasRegistered($user));
     return $user;
 }
Exemplo n.º 11
0
 /**
  * [register description]
  * @param  [type] $username [description]
  * @param  [type] $email    [description]
  * @param  [type] $password [description]
  * @return [type]           [description]
  */
 public static function register($username, $email, $password)
 {
     $user = new static(compact('username', 'email', 'password'));
     $path = public_path();
     $parentDir = $path . '/img/users/' . $email . '/';
     if (!file_exists($parentDir)) {
         mkdir($parentDir, 0777, true);
     }
     $user->raise(new UserRegistered($user));
     return $user;
 }
Exemplo n.º 12
0
 /**
  * Create a new instance in reply to a discussion.
  *
  * @param  int  $discussionId
  * @param  string  $content
  * @param  int  $userId
  * @return static
  */
 public static function reply($discussionId, $content, $userId)
 {
     $post = new static();
     $post->content = $content;
     $post->time = time();
     $post->discussion_id = $discussionId;
     $post->user_id = $userId;
     $post->type = 'comment';
     $post->raise(new PostWasPosted($post));
     return $post;
 }
Exemplo n.º 13
0
 /**
  * Create a new instance in reply to a discussion.
  *
  * @param int $discussionId
  * @param string $content
  * @param int $userId
  * @return static
  */
 public static function reply($discussionId, $content, $userId)
 {
     $post = new static();
     $post->time = time();
     $post->discussion_id = $discussionId;
     $post->user_id = $userId;
     $post->type = static::$type;
     // Set content last, as the parsing may rely on other post attributes.
     $post->content = $content;
     $post->raise(new PostWasPosted($post));
     return $post;
 }
Exemplo n.º 14
0
 public function savePageOrThrowException($title, $slug = null, $content, $template)
 {
     $slug = $this->createSlug($slug, $title);
     $page = new static();
     $page->title = $title;
     $page->content = $content;
     $page->template = $template;
     $page->author()->associate(\Auth::user());
     if ($page->save()) {
         $page->raise(new PageWasPublished($page, $slug));
     }
     return $page;
 }
Exemplo n.º 15
0
 /**
  * Publish a new status
  * @param  [type] $body [description]
  * @return [type]       [description]
  */
 public static function publish($user_id, $body, $global)
 {
     $body = Crypt::encrypt($body);
     $message = new static(compact('user_id', 'body', 'global'));
     $message->raise(new GlobalMessagePublished($user_id, $body));
     return $message;
 }
Exemplo n.º 16
0
 public static function request($sender_id, $receiver_id, $pending)
 {
     $request = new static(compact('sender_id', 'receiver_id', 'pending'));
     $request->raise(new FriendRequestPublished($sender_id, $receiver_id, $pending));
     return $request;
 }
Exemplo n.º 17
0
 /**
  * Publish a new status
  * @param  [type] $body [description]
  * @return [type]       [description]
  */
 public static function publish($user_id, $body, $global, $incognito)
 {
     $body = Crypt::encrypt($body);
     $message = new static(compact('user_id', 'body', 'global', 'incognito'));
     switch ($global) {
         case "1":
             $message->raise(new GlobalMessagePublished($user_id, $body, $incognito, $global));
             break;
         case "2":
             $message->raise(new FriendsMessagePublished($user_id, $body, $incognito, $global));
             break;
         case "3":
             $message->raise(new GroupMessagePublished($user_id, $body, $incognito, $global));
             break;
         default:
             break;
     }
     return $message;
 }
Exemplo n.º 18
0
 /**
  * Generate a New Contract
  * @param $attributes
  *
  * @raises event
  * @return mixed
  */
 public static function generate($attributes)
 {
     $contract = new static($attributes);
     $contract->raise(new ContractCreated($contract));
     return $contract;
 }
Exemplo n.º 19
0
 /**
  * @param $email
  * @param $password
  * @param $first_name
  * @param $last_name
  * @return static
  */
 public static function registerNewUser($email, $password, $first_name, $last_name)
 {
     $user = new static(compact('email', 'password', 'first_name', 'last_name'));
     $user->raise(new UserRegistered($user));
     return $user;
 }
Exemplo n.º 20
0
 public static function register($name, $email, $password, $cat_one, $cat_two, $cat_three, $sex)
 {
     $user = new static(compact('name', 'email', 'password', 'cat_one', 'cat_two', 'cat_three', 'sex'));
     $user->raise(new UserHasRegistered($user));
     return $user;
 }
Exemplo n.º 21
0
 /**
  * publish
  *
  * @param mixed $body description
  *
  * @return mixed
  * @author Alonzo Tolver <*****@*****.**>
  *
  **/
 public static function publish($body)
 {
     $status = new static(compact('body'));
     $status->raise(new StatusWasPublished($body));
     return $status;
 }
Exemplo n.º 22
0
 /**
  * Publish a new status
  * @param  [type] $body [description]
  * @return [type]       [description]
  */
 public static function publish($user_id, $type, $post_id)
 {
     $update = new static(compact('user_id', 'type', 'post_id'));
     $update->raise(new UpdatePublished($user_id, $type, $post_id));
     return $update;
 }
Exemplo n.º 23
0
 /**
  * Login a user Event generator
  * @param $email
  * @param $password
  * @return static
  */
 public function login($email, $password)
 {
     $user = new static(compact('email', 'password'));
     $user->raise(new UserHasLoggedIn($email, $password));
     return $user;
 }
Exemplo n.º 24
0
 /**
  * Generate a new link
  * @param $user_id
  * @param $url
  * @param $hash
  * @return static
  */
 public function generate($user_id, $url, $hash)
 {
     $link = new static(compact('user_id', 'url', 'hash'));
     $link->raise(new LinkWasGenerated($user_id, $url, $hash));
     return $link;
 }
Exemplo n.º 25
0
 /**
  * Should create a new instance of the entity, with the first name, last name and email provided.
  *
  * @param string $firstName
  * @param string $lastName
  * @param string $email
  * @param string $password
  * @return User
  */
 public static function add($firstName, $lastName, $email, $password)
 {
     $user = new static(compact('firstName', 'lastName', 'email', 'password'));
     $user->raise(new UserWasAdded($user));
     return $user;
 }
Exemplo n.º 26
0
 /**
  * @param $username
  * @param $email
  * @param $password
  * @return static
  */
 public static function register($username, $email, $password)
 {
     $user = new static(compact('username', 'email', 'password'));
     $user->raise(new UserHasRegistered($user));
     return $user;
 }
Exemplo n.º 27
0
 /**
  * Create a new account instance.
  *
  * @param array $attributes
  * @return static
  */
 public static function create(array $attributes)
 {
     $account = new static($attributes);
     $account->raise(new AccountWasCreated($account));
     return $account;
 }