<commit_before><?php namespace GrahamCampbell\CMSCore\Models;

/**
 * This file is part of CMS Core by <NAME>.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * @package    CMS-Core
 * @author     <NAME>
 * @license    GNU AFFERO GENERAL PUBLIC LICENSE
 * @copyright  Copyright (C) 2013  <NAME>
 * @link       https://github.com/GrahamCampbell/CMS-Core
 */

use Event as LaravelEvent;

use Cartalyst\Sentry\Users\Eloquent\User as SentryUser;

class User extends SentryUser implements Interfaces\IBaseModel, Interfaces\INameModel, Relations\Interfaces\IHasManyPages, Relations\Interfaces\IHasManyPosts, Relations\Interfaces\IHasManyEvents, Relations\Interfaces\IHasManyComments {

    use Common\TraitBaseModel, Common\TraitNameModel, Relations\Common\TraitHasManyPages, Relations\Common\TraitHasManyPosts, Relations\Common\TraitHasManyEvents, Relations\Common\TraitHasManyComments;

    /**
     * The table the users are stored in.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The model name.
     *
     * @var string
     */
    public static $name = 'user';

    /**
     * The columns to select when displaying an index.
     *
     * @var array
     */
    public static $index = array('id', 'email', 'first_name', 'last_name');

    /**
     * The max users per page when displaying a paginated index.
     *
     * @var int
     */
    public static $paginate = 20;

    /**
     * The columns to order by when displaying an index.
     *
     * @var string
     */
    public static $order = 'email';

    /**
     * The direction to order by when displaying an index.
     *
     * @var string
     */
    public static $sort = 'asc';

    /**
     * Get email.
     *
     * @param  array  $input
     * @return void
     */
    public function getEmail() {
        return $this->email;
    }


    /**
     * Get activated_at.
     *
     * @return mixed
     */
    public function getActivatedAt() {
        $activated = $this->activated_at;

        if ($activated) {
            return new Carbon($activated);
        }

        return 'Not Activated';
    }

    /**
     * Create a new user.
     *
     * @param  array  $input
     * @return \GrahamCampbell\CMSCore\Models\User
     */
    public static function create(array $input) {
        $return = parent::create($input);
        LaravelEvent::fire('user.created');
        return $return;
    }

    /**
     * Update an existing user.
     *
     * @param  array  $input
     * @return \GrahamCampbell\CMSCore\Models\User
     */
    public function update(array $input = array()) {
        $return = parent::update($input);
        LaravelEvent::fire('user.updated');
        return $return;
    }

    /**
     * Delete an existing user.
     *
     * @param  array  $input
     * @return void
     */
    public function delete() {
        $this->deletePages();
        $this->deletePosts();
        $this->deleteEvents();
        $this->deleteComments();
        $return = parent::delete();
        LaravelEvent::fire('user.deleted');
        return $return;
    }
}
<commit_msg>User model tweaks<commit_after><?php namespace GrahamCampbell\CMSCore\Models;

/**
 * This file is part of CMS Core by <NAME>.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * @package    CMS-Core
 * @author     <NAME>
 * @license    GNU AFFERO GENERAL PUBLIC LICENSE
 * @copyright  Copyright (C) 2013  <NAME>
 * @link       https://github.com/GrahamCampbell/CMS-Core
 */

use Event as LaravelEvent;
use Carbon\Carbon;

use Cartalyst\Sentry\Users\Eloquent\User as SentryUser;

class User extends SentryUser implements Interfaces\IBaseModel, Interfaces\INameModel, Relations\Interfaces\IHasManyPages, Relations\Interfaces\IHasManyPosts, Relations\Interfaces\IHasManyEvents, Relations\Interfaces\IHasManyComments {

    use Common\TraitBaseModel, Common\TraitNameModel, Relations\Common\TraitHasManyPages, Relations\Common\TraitHasManyPosts, Relations\Common\TraitHasManyEvents, Relations\Common\TraitHasManyComments;

    /**
     * The table the users are stored in.
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * The model name.
     *
     * @var string
     */
    public static $name = 'user';

    /**
     * The columns to select when displaying an index.
     *
     * @var array
     */
    public static $index = array('id', 'email', 'first_name', 'last_name');

    /**
     * The max users per page when displaying a paginated index.
     *
     * @var int
     */
    public static $paginate = 20;

    /**
     * The columns to order by when displaying an index.
     *
     * @var string
     */
    public static $order = 'email';

    /**
     * The direction to order by when displaying an index.
     *
     * @var string
     */
    public static $sort = 'asc';

    /**
     * Get email.
     *
     * @param  array  $input
     * @return void
     */
    public function getEmail() {
        return $this->email;
    }


    /**
     * Get activated_at.
     *
     * @return \Carbon\Carbon
     */
    public function getActivatedAt() {
        $activated_at = $this->activated_at;

        if ($activated_at) {
            return new Carbon($activated_at);
        }

        if ($this->activated) {
            return $this->getCreatedAt();
        }

        return null;
    }

    /**
     * Create a new user.
     *
     * @param  array  $input
     * @return \GrahamCampbell\CMSCore\Models\User
     */
    public static function create(array $input) {
        $return = parent::create($input);
        LaravelEvent::fire('user.created');
        return $return;
    }

    /**
     * Update an existing user.
     *
     * @param  array  $input
     * @return \GrahamCampbell\CMSCore\Models\User
     */
    public function update(array $input = array()) {
        $return = parent::update($input);
        LaravelEvent::fire('user.updated');
        return $return;
    }

    /**
     * Delete an existing user.
     *
     * @param  array  $input
     * @return void
     */
    public function delete() {
        $this->deletePages();
        $this->deletePosts();
        $this->deleteEvents();
        $this->deleteComments();
        $return = parent::delete();
        LaravelEvent::fire('user.deleted');
        return $return;
    }
}

{'fraction_non_alphanumeric': 0.11092738046024528, 'fraction_numerical': 0.0019291718340912222, 'mean_word_length': 2.3141552511415524, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4218092', 'n_tokens_mistral': 2170, 'n_tokens_neox': 2062, 'n_words': 623}