forked from monicahq/monica
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set currency and timezone for new users (monicahq#1657)
- Loading branch information
Showing
13 changed files
with
969 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Http\Location\Drivers; | ||
|
||
use App\Helpers\RequestHelper; | ||
use Illuminate\Support\Fluent; | ||
use Stevebauman\Location\Position; | ||
use Illuminate\Support\Facades\Request; | ||
use Stevebauman\Location\Drivers\Driver; | ||
|
||
class CloudflareDriver extends Driver | ||
{ | ||
public function url() | ||
{ | ||
} | ||
|
||
protected function hydrate(Position $position, Fluent $location) | ||
{ | ||
$position->countryCode = $location->country_code; | ||
|
||
return $position; | ||
} | ||
|
||
protected function process($ip = null) | ||
{ | ||
if (! is_null($ip)) { | ||
return $this->fallback->get($ip); | ||
} | ||
|
||
try { | ||
return $this->getCountry(); | ||
} catch (\Exception $e) { | ||
return false; | ||
} | ||
} | ||
|
||
private function getCountry() | ||
{ | ||
$country = Request::header('Cf-Ipcountry'); | ||
|
||
if (! is_null($country)) { | ||
$response = ['country_code' => $country]; | ||
|
||
return new Fluent($response); | ||
} | ||
|
||
return $this->fallback->get(RequestHelper::ip()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.