コード例 #1
0
ファイル: UserController.php プロジェクト: gsdw/permission
 /**
  * Edit role
  *
  * @return void
  */
 public function edit($id)
 {
     $model = User::find($id);
     if (!count($model)) {
         return redirect()->route($this->prefixPathRoute . 'list')->withErrors('Not found user');
     }
     Form::setData($model);
     return view('gsdw_permission::user.edit', ['title' => 'Edit user: ' . $model->name]);
 }
コード例 #2
0
ファイル: rule.blade.php プロジェクト: gsdw/permission
<?php

$i = 0;
$rules = \Gsdw\Base\Helpers\Form::getData('rule');
$rules = (array) $rules;
$routeCollection = Gsdw\Permission\Helpers\General::getRouterAs();
?>
<div class="rule-path-list format-tree">
    <div class="form-group rule-all-group">
        <span class="input-box">
            <input type="checkbox" name="rule[]" value="all"
                class="input-checkbox rule-checkbox-item" id="rule-all"
                <?php 
if (in_array(Gsdw\Permission\Models\RoleScope::RULE_ALL, $rules)) {
    ?>
 checked<?php 
}
?>
/>
        </span>
        <label class="control-label" for="rule-all">All</label>
    </div>
    
    @if(count($routeCollection))
        <div class="rule-item-group">
            @foreach ($routeCollection as $routeKey => $routeName)
                <?php 
$i++;
?>
                <div class="form-group">
                    <span class="input-box">
コード例 #3
0
ファイル: general.blade.php プロジェクト: gsdw/permission
<div class="form-group">
    <label class="col-sm-2 control-label" for="item-email">Email</label>
    <div class="col-sm-10">
        <input type="text" name="item[email]" id="item-email" 
            class="form-control" placeholder="Email" value="{{ Form::getData('email') }}" />
    </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label" for="item-group">Role</label>
    <div class="col-sm-10">
        <select name="item[role_id]" id="item-group" class="form-control">
            @foreach (\Gsdw\Permission\Models\Role::toOption() as $option)
                <option value="{{ $option['value'] }}" <?php 
if (Form::getData('role_id') == $option['value']) {
    echo ' selected';
}
?>
>{{ $option['label'] }}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label" for="item-name">Password</label>
    <div class="col-sm-10">
        <input type="password" name="item[password]" id="item-password" 
            class="form-control" placeholder="Password" />
    </div>
コード例 #4
0
 /**
  * Save role
  *
  * @return void
  */
 public function editPost(Request $request, $id)
 {
     try {
         $model = RoleGroup::find($id);
         if (!count($model)) {
             return redirect()->route($this->prefixPathRoute . 'list')->withErrors('Not found role group');
         }
         $input = $request->input('item');
         $validator = Validator::make($input, ['name' => 'required|unique:role_group,name,' . $id . '|max:255']);
         if ($validator->fails()) {
             Form::setData($model);
             return redirect()->route($this->prefixPathRoute . 'editForm', ['id' => $id])->withErrors($validator);
         }
         $model->update($input);
         $messages = array('success' => ['Save role group success!']);
         if ($request->input('submit_continue')) {
             return redirect()->route($this->prefixPathRoute . 'editForm', ['id' => $id])->with('messages', $messages);
         }
         return redirect()->route($this->prefixPathRoute . 'list')->with('messages', $messages);
     } catch (Exception $ex) {
         return redirect()->route($this->prefixPathRoute . 'editForm', ['id' => $id])->withErrors($ex)->withInput();
     }
 }