@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | public function __construct() |
19 | 19 | { |
20 | 20 | if (config('ipchecker.settings.auth')) { |
21 | - $this->middleware(['web','auth']); |
|
21 | + $this->middleware(['web', 'auth']); |
|
22 | 22 | } |
23 | - elseif(config('ipchecker.settings.middleware')){ |
|
23 | + elseif (config('ipchecker.settings.middleware')) { |
|
24 | 24 | $this->middleware(config('ipchecker.settings.middleware')); |
25 | 25 | } |
26 | 26 | } |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | { |
36 | 36 | $iplist = $ipchecker->getIpList(); |
37 | 37 | |
38 | - if(count($iplist)>0){ |
|
38 | + if (count($iplist)>0) { |
|
39 | 39 | $iplist = $iplist->sortByDesc('created_at'); |
40 | 40 | } |
41 | 41 | |
42 | - return view('ipchecker::index',compact('iplist')); |
|
42 | + return view('ipchecker::index', compact('iplist')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param IpCheckerInterface $ipchecker |
48 | 48 | * @return \Illuminate\Http\RedirectResponse |
49 | 49 | */ |
50 | - public function add(Request $request,IpCheckerInterface $ipchecker) |
|
50 | + public function add(Request $request, IpCheckerInterface $ipchecker) |
|
51 | 51 | { |
52 | 52 | $request_data = $request->all(); |
53 | 53 | $request_validation = array( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param IpCheckerInterface $ipchecker |
75 | 75 | * @return \Illuminate\Http\RedirectResponse |
76 | 76 | */ |
77 | - public function delete(Request $request,IpCheckerInterface $ipchecker) |
|
77 | + public function delete(Request $request, IpCheckerInterface $ipchecker) |
|
78 | 78 | { |
79 | 79 | $ipchecker->deleteIp($request->input('ipAddress')); |
80 | 80 |
@@ -19,8 +19,7 @@ |
||
19 | 19 | { |
20 | 20 | if (config('ipchecker.settings.auth')) { |
21 | 21 | $this->middleware(['web','auth']); |
22 | - } |
|
23 | - elseif(config('ipchecker.settings.middleware')){ |
|
22 | + } elseif(config('ipchecker.settings.middleware')){ |
|
24 | 23 | $this->middleware(config('ipchecker.settings.middleware')); |
25 | 24 | } |
26 | 25 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use HayriCan\IpChecker\Contracts\IpCheckerInterface; |
6 | 6 | |
7 | -class DBDriver implements IpCheckerInterface{ |
|
7 | +class DBDriver implements IpCheckerInterface { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Model for saving logs |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function getIpArray() |
26 | 26 | { |
27 | - foreach ($this->model->all() as $record){ |
|
28 | - array_push($this->ipList,$record->ip); |
|
27 | + foreach ($this->model->all() as $record) { |
|
28 | + array_push($this->ipList, $record->ip); |
|
29 | 29 | } |
30 | 30 | $ipList = $this->ipList ?? []; |
31 | 31 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function saveIp($array) |
48 | 48 | { |
49 | 49 | $result = IpList::create($array); |
50 | - if (!$result){ |
|
50 | + if (!$result) { |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | public function deleteIp($ipAddress) |
62 | 62 | { |
63 | 63 | $response = false; |
64 | - $ipList = IpList::where('ip',$ipAddress)->first(); |
|
65 | - if ($ipList){ |
|
66 | - IpList::where('id',$ipList->id)->delete(); |
|
64 | + $ipList = IpList::where('ip', $ipAddress)->first(); |
|
65 | + if ($ipList) { |
|
66 | + IpList::where('id', $ipList->id)->delete(); |
|
67 | 67 | $response = true; |
68 | 68 | } |
69 | 69 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function saveIp($array) |
77 | 77 | { |
78 | - $array['created_at']=Carbon::now()->toDateTimeString(); |
|
78 | + $array['created_at'] = Carbon::now()->toDateTimeString(); |
|
79 | 79 | $filename = $this->getFilename(); |
80 | 80 | |
81 | 81 | $contents = implode(";", $array); |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | if (!is_dir($file)) { |
101 | 101 | $lines = file($this->path.DIRECTORY_SEPARATOR.$file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
102 | 102 | foreach ($lines as $line) { |
103 | - if (strpos($line, $ipAddress)){ |
|
103 | + if (strpos($line, $ipAddress)) { |
|
104 | 104 | $contents = file_get_contents($this->path.DIRECTORY_SEPARATOR.$file); |
105 | - $contents = str_replace($line,'',$contents); |
|
106 | - file_put_contents($this->path.DIRECTORY_SEPARATOR.$file,$contents); |
|
105 | + $contents = str_replace($line, '', $contents); |
|
106 | + file_put_contents($this->path.DIRECTORY_SEPARATOR.$file, $contents); |
|
107 | 107 | return true; |
108 | 108 | } |
109 | 109 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param array $data |
123 | 123 | * @return IpList |
124 | 124 | */ |
125 | - public function mapArrayToModel(array $data){ |
|
125 | + public function mapArrayToModel(array $data) { |
|
126 | 126 | $model = new IpList(); |
127 | 127 | $model->group = $data[0]; |
128 | 128 | $model->definition = $data[1]; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function getFilename() |
140 | 140 | { |
141 | 141 | $filename = 'iplist.php'; |
142 | - if (config('ipchecker.filename')){ |
|
142 | + if (config('ipchecker.filename')) { |
|
143 | 143 | $filename = config('ipchecker.filename'); |
144 | 144 | } |
145 | 145 |