Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadSH committed Apr 5, 2020
1 parent 863618b commit 6311a8f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
//use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -18,9 +18,9 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
if ($this->app->environment() !== 'production') {
$this->app->register(IdeHelperServiceProvider::class);
}
// if ($this->app->environment() !== 'production') {
// $this->app->register(IdeHelperServiceProvider::class);
// }
}

/**
Expand All @@ -42,7 +42,7 @@ private function defineValidationRules(): void
if (strcmp($parameters[0], 'national_code') === 0) {
return $this->validateNationalCode($value);
}

return true;
});
}
Expand All @@ -52,23 +52,23 @@ private function validateNationalCode($value)
if (!preg_match('/^[0-9]{10}$/', $value)) {
$flag = false;
}

for ($i = 0; $i < 10; $i++) {
if (preg_match('/^'.$i.'{10}$/', $value)) {
$flag = false;
}
}

for ($i = 0, $sum = 0; $i < 9; $i++) {
$sum += ((10 - $i) * intval(substr($value, $i, 1)));
}

$ret = $sum % 11;
$parity = intval(substr($value, 9, 1));
if (($ret < 2 && $ret === $parity) || ($ret >= 2 && $ret === 11 - $parity)) {
$flag = true;
}

return $flag;
}
}

0 comments on commit 6311a8f

Please sign in to comment.