Commit ae74cc2f authored by Nicolas Widart's avatar Nicolas Widart

Fix merge conflict

parents 46b2698a f4edb764
......@@ -2,8 +2,9 @@
use Cartalyst\Sentinel\Users\EloquentUser;
use Laracasts\Presenter\PresentableTrait;
use Modules\User\Entities\UserInterface;
class User extends EloquentUser
class User extends EloquentUser implements UserInterface
{
use PresentableTrait;
......@@ -16,4 +17,9 @@ class User extends EloquentUser
];
protected $presenter = 'Modules\User\Presenters\UserPresenter';
public function hasRole($roleId)
{
return $this->roles()->whereId($roleId)->count() >= 1;
}
}
......@@ -2,8 +2,9 @@
use Cartalyst\Sentry\Users\Eloquent\User as SentryModel;
use Laracasts\Presenter\PresentableTrait;
use Modules\User\Entities\UserInterface;
class User extends SentryModel
class User extends SentryModel implements UserInterface
{
use PresentableTrait;
......@@ -21,4 +22,13 @@ class User extends SentryModel
{
return $this->belongsToMany(static::$groupModel, static::$userGroupsPivot, 'user_id');
}
/**
* Checks if a user belongs to the given Role ID
* @param int $roleId
* @return bool
*/
public function hasRole($roleId)
{
}
}
<?php namespace Modules\User\Entities;
interface UserInterface
{
/**
* Checks if a user belongs to the given Role ID
* @param int $roleId
* @return bool
*/
public function hasRole($roleId);
}
......@@ -60,7 +60,7 @@
<label>{{ trans('user::users.tabs.roles') }}</label>
<select multiple="" class="form-control" name="roles[]">
<?php foreach($roles as $role): ?>
<option value="{{ $role->id }}" <?php echo $user->roles()->whereId($role->id)->count() >= 1 ? 'selected' : '' ?>>{{ $role->name }}</option>
<option value="{{ $role->id }}" <?php echo $user->hasRole($role->id) ? 'selected' : '' ?>>{{ $role->name }}</option>
<?php endforeach; ?>
</select>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment