FirstUser.php 744 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Rules;
  3. use Illuminate\Contracts\Validation\Rule;
  4. use Illuminate\Support\Facades\DB;
  5. class FirstUser implements Rule
  6. {
  7. /**
  8. * Create a new rule instance.
  9. *
  10. * @return void
  11. */
  12. public function __construct()
  13. {
  14. //
  15. }
  16. /**
  17. * Determine if the validation rule passes.
  18. *
  19. * @param string $attribute
  20. * @param mixed $value
  21. * @return bool
  22. */
  23. public function passes($attribute, $value)
  24. {
  25. return DB::table('users')->count() === 0 ? true : false;
  26. }
  27. /**
  28. * Get the validation error message.
  29. *
  30. * @return string
  31. */
  32. public function message()
  33. {
  34. return trans('validation.custom.name.firstUser');
  35. }
  36. }