Created
January 30, 2021 14:15
-
-
Save alexjustesen/e3fbb3e5e670cbf1a4c63f075e6fb7da to your computer and use it in GitHub Desktop.
Laravel Timezone model with Sushi
This file contains hidden or 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 model requires https://github.com/calebporzio/sushi: composer require calebporzio/sushi --> | |
| <?php | |
| namespace App\Models; | |
| use Illuminate\Database\Eloquent\Model; | |
| class Timezone extends Model | |
| { | |
| use \Sushi\Sushi; | |
| public function getRows() | |
| { | |
| return collect(timezone_identifiers_list()) | |
| ->map(function ($item) { | |
| return [ | |
| 'identifier' => $item, | |
| 'string' => '(GMT' . now($item)->format('O') . ') ' . $item . ' (' . now($item)->format('T') . ')', | |
| ]; | |
| }) | |
| ->toArray(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment