Ejemplo n.º 1
0
 public function assignRoleFeature($role_id)
 {
     try {
         $feature_id = Input::get('feature_id');
         $already_assigned = FeatureRole::where('role_id', $role_id)->where('feature_id', $feature_id)->exists();
         if ($already_assigned) {
             return Redirect::to("/crm/role/{$role_id}")->withMessage(Generate::error_message('Fail', 'This feature is already assigned to this role.'));
         }
         $new_assign_feature = ['role_id' => $role_id, 'feature_id' => $feature_id, 'order' => 1];
         FeatureRole::create($new_assign_feature);
         return Redirect::to("/crm/role/{$role_id}")->withMessage(Generate::success_message('Success', 'Assigned Successfully'));
     } catch (Exception $e) {
         return Redirect::to("/crm/role/{$role_id}")->withMessage(Generate::error_message('Fail', 'Failed to assign feature.'));
     }
 }