<commit_before><?php namespace Orchestra\Model;

use Illuminate\Database\Eloquent\Model as Eloquent;

class Role extends Eloquent {

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'roles';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = array(
		'name',
	);

	/**
	 * Has many and belongs to relationship with User.
	 *
	 * @access public
	 * @return Illuminate\Database\Eloquent\Relations\BelongsToMany
	 */
	public function users() 
	{
		return $this->belongsToMany('\Orchestra\Model\User', 'user_role');
	}<commit_msg>[#1] Add Orchestra\Model\Role events to update ACL.<commit_after><?php namespace Orchestra\Model;

use Illuminate\Database\Eloquent\Model as Eloquent,
	Orchestra\Acl;

class Role extends Eloquent {

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'roles';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = array(
		'name',
	);

	/**
	 * Has many and belongs to relationship with User.
	 *
	 * @access public
	 * @return Illuminate\Database\Eloquent\Relations\BelongsToMany
	 */
	public function users() 
	{
		return $this->belongsToMany('\Orchestra\Model\User', 'user_role');
	}

	/**
	 * The "booting" method of the model.
	 *
	 * @return void
	 */
	protected static function boot()
	{
		parent::boot();

		static::creating(function ($role)
		{
			Acl::addRole($role->name);
		});

		static::updating(function ($role)
		{
			$oldName = $role->original['name'];
			Acl::renameRole($oldName, $role->name);
		});

		static::deleting(function ($role)
		{
			Acl::removeRole($role->name);
		});
	}
{'fraction_non_alphanumeric': 0.14873603762492651, 'fraction_numerical': 0.0005878894767783657, 'mean_word_length': 3.397932816537468, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '7419277', 'n_tokens_mistral': 619, 'n_tokens_neox': 561, 'n_words': 138}