@@ -29,7 +29,7 @@ |
||
| 29 | 29 | 'code'=>250, |
| 30 | 30 | 'message'=>'Your IP Address not in the list.', |
| 31 | 31 | ); |
| 32 | - return response()->json($return_array,250,[],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
| 32 | + return response()->json($return_array, 250, [], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return $next($request); |
@@ -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']); |
|
| 22 | - }else{ |
|
| 23 | - if(config('ipchecker.settings.middleware')){ |
|
| 21 | + $this->middleware(['web', 'auth']); |
|
| 22 | + } else { |
|
| 23 | + if (config('ipchecker.settings.middleware')) { |
|
| 24 | 24 | $this->middleware(config('ipchecker.settings.middleware')); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $iplist = $ipchecker->getIpList(); |
| 38 | 38 | |
| 39 | - if(count($iplist)>0){ |
|
| 39 | + if (count($iplist)>0) { |
|
| 40 | 40 | $iplist = $iplist->sortByDesc('created_at'); |
| 41 | 41 | } |
| 42 | - else{ |
|
| 42 | + else { |
|
| 43 | 43 | $iplist = []; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return view('ipchecker::index',compact('iplist')); |
|
| 46 | + return view('ipchecker::index', compact('iplist')); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param IpCheckerInterface $ipchecker |
| 52 | 52 | * @return \Illuminate\Http\RedirectResponse |
| 53 | 53 | */ |
| 54 | - public function add(Request $request,IpCheckerInterface $ipchecker) |
|
| 54 | + public function add(Request $request, IpCheckerInterface $ipchecker) |
|
| 55 | 55 | { |
| 56 | 56 | $request_data = $request->all(); |
| 57 | 57 | $request_validation = array( |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param IpCheckerInterface $ipchecker |
| 79 | 79 | * @return \Illuminate\Http\RedirectResponse |
| 80 | 80 | */ |
| 81 | - public function delete(Request $request,IpCheckerInterface $ipchecker) |
|
| 81 | + public function delete(Request $request, IpCheckerInterface $ipchecker) |
|
| 82 | 82 | { |
| 83 | 83 | $ipchecker->deleteIp($request->input('ipAddress')); |
| 84 | 84 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | if (config('ipchecker.settings.auth')) { |
| 21 | 21 | $this->middleware(['web','auth']); |
| 22 | - }else{ |
|
| 22 | + } else{ |
|
| 23 | 23 | if(config('ipchecker.settings.middleware')){ |
| 24 | 24 | $this->middleware(config('ipchecker.settings.middleware')); |
| 25 | 25 | } |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | if(count($iplist)>0){ |
| 40 | 40 | $iplist = $iplist->sortByDesc('created_at'); |
| 41 | - } |
|
| 42 | - else{ |
|
| 41 | + } else{ |
|
| 43 | 42 | $iplist = []; |
| 44 | 43 | } |
| 45 | 44 | |
@@ -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,8 +61,8 @@ discard block |
||
| 61 | 61 | public function deleteIp($ip) |
| 62 | 62 | { |
| 63 | 63 | $response = false; |
| 64 | - $ipList = IpList::where('ip',$ip)->first(); |
|
| 65 | - if ($ipList){ |
|
| 64 | + $ipList = IpList::where('ip', $ip)->first(); |
|
| 65 | + if ($ipList) { |
|
| 66 | 66 | IpList::destroy($ipList->id); |
| 67 | 67 | $response = true; |
| 68 | 68 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | 6 | |
| 7 | -interface IpCheckerInterface{ |
|
| 7 | +interface IpCheckerInterface { |
|
| 8 | 8 | |
| 9 | 9 | public function getIpArray(); |
| 10 | 10 | /** |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public function register() |
| 21 | 21 | { |
| 22 | 22 | $this->mergeConfigFrom( |
| 23 | - __DIR__ . '/../config/ipchecker.php', 'ipchecker' |
|
| 23 | + __DIR__.'/../config/ipchecker.php', 'ipchecker' |
|
| 24 | 24 | ); |
| 25 | 25 | $this->bindServices(); |
| 26 | 26 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $this->loadMigrations(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function bindServices(){ |
|
| 35 | + public function bindServices() { |
|
| 36 | 36 | $driver = config('ipchecker.driver'); |
| 37 | 37 | switch ($driver) { |
| 38 | 38 | case 'file': |
@@ -45,29 +45,29 @@ discard block |
||
| 45 | 45 | throw new Exception("Unsupported Driver"); |
| 46 | 46 | break; |
| 47 | 47 | } |
| 48 | - $this->app->singleton(IpCheckerInterface::class,$instance); |
|
| 48 | + $this->app->singleton(IpCheckerInterface::class, $instance); |
|
| 49 | 49 | |
| 50 | - $this->app->singleton('ipchecker', function ($app) use ($instance){ |
|
| 50 | + $this->app->singleton('ipchecker', function($app) use ($instance){ |
|
| 51 | 51 | return new IpChecker($app->make($instance)); |
| 52 | 52 | }); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function loadConfig(){ |
|
| 55 | + public function loadConfig() { |
|
| 56 | 56 | $this->publishes([ |
| 57 | - __DIR__ . '/../config/ipchecker.php' => config_path('ipchecker.php') |
|
| 57 | + __DIR__.'/../config/ipchecker.php' => config_path('ipchecker.php') |
|
| 58 | 58 | ], 'config'); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function loadRoutes(){ |
|
| 62 | - $this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); |
|
| 61 | + public function loadRoutes() { |
|
| 62 | + $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function loadViews(){ |
|
| 66 | - $this->loadViewsFrom(__DIR__ . '/../resources/views', 'ipchecker'); |
|
| 65 | + public function loadViews() { |
|
| 66 | + $this->loadViewsFrom(__DIR__.'/../resources/views', 'ipchecker'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function loadMigrations(){ |
|
| 70 | - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
| 69 | + public function loadMigrations() { |
|
| 70 | + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | \ No newline at end of file |
@@ -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, $ip)){ |
|
| 103 | + if (strpos($line, $ip)) { |
|
| 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 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('ip_lists', function (Blueprint $table) { |
|
| 16 | + Schema::create('ip_lists', function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->string('group'); |
| 19 | 19 | $table->string('definition'); |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | |
| 15 | -Route::group(['prefix'=>config('ipchecker.settings.route_prefix')], function () { |
|
| 15 | +Route::group(['prefix'=>config('ipchecker.settings.route_prefix')], function() { |
|
| 16 | 16 | Route::get('/iplists', 'HayriCan\IpChecker\Http\Controllers\IpCheckerController@index')->name('iplist.index'); |
| 17 | 17 | Route::post('/ip-add', 'HayriCan\IpChecker\Http\Controllers\IpCheckerController@add')->name('iplist.add'); |
| 18 | 18 | Route::delete('/ip-delete', 'HayriCan\IpChecker\Http\Controllers\IpCheckerController@delete')->name('iplist.delete'); |