/** * 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; }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * [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; }
/** * 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; }
/** * 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; }
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; }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
/** * @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; }
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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * @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; }
/** * 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; }