/** * Execute the console command. * * @return mixed */ public function fire() { // $uid = posix_getuid(); $this->info("UID is {$uid}"); // Get the rules we need to add $rules = FirewallRule::whereActive(0)->get(); foreach ($rules as $rule) { // Add the rule to iptables exec($this->genString($rule)); // Mark rule as active in DB $rule->active = 1; $rule->save(); } // See if there are any rules to delete $deletedRules = FirewallRule::onlyTrashed()->get(); foreach ($deletedRules as $rule) { exec($this->genString($rule)); $rule->forceDelete(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $rule = FirewallRule::findOrFail($id); $rule->delete(); return 1; }