Beispiel #1
0
 /**
  * [getPolicyByKeywork fetch array by key work or searching]
  * @param  [string] $keywork [key word for search policy]
  * @param  [integer] $perPage [limit result per page]
  * @return [array]          [collect of policy]
  */
 public function getPolicyByKeywork($keywork, $perPage)
 {
     if ($keywork != 'all') {
         $policy = Policy::whereRaw('policy_content like ? or author like ?', array('%' . $keywork . '%', '%' . $keywork . '%'))->orderBy('id', 'asc')->paginate($perPage);
     } else {
         $policy = Policy::where('policy_content', '!=', '')->orderBy('id', 'asc')->paginate($perPage);
     }
     return $policy;
 }
Beispiel #2
0
 /**
  * [policyDelAction for remove policy from database]
  * @param  [integer] $id [policy id]
  * @return [none]     [redirect to policy page]
  */
 public function policyDelAction($id)
 {
     try {
         $policy = new Policy();
         $policy->setTable('policy');
         $policy->where('id', '=', $id)->delete();
         //Policy::table('policy')->where('id','=',$id)->delete();
         RolePolicy::where('policy_id', '=', $id)->delete();
         ActionPolicy::where('policy_id', '=', $id)->delete();
         DataPolicy::where('policy_id', '=', $id)->delete();
         ConditionPolicy::where('policy_id', '=', $id)->delete();
         ObligationPolicy::where('policy_id', '=', $id)->delete();
         PurposePolicy::where('policy_id', '=', $id)->delete();
         return Redirect::to('policy-content')->with('success', 'มีนโยบายคลังฯรหัส = ' . $id . ' ลบทิ้งสำเร็จ');
     } catch (Exception $e) {
         return Redirect::to('policy-content')->withErrors(array('Caught exception: ' . $e->getMessage()));
     }
 }