Skip to content

Instantly share code, notes, and snippets.

@alexjustesen
Created January 30, 2021 14:15
Show Gist options
  • Select an option

  • Save alexjustesen/e3fbb3e5e670cbf1a4c63f075e6fb7da to your computer and use it in GitHub Desktop.

Select an option

Save alexjustesen/e3fbb3e5e670cbf1a4c63f075e6fb7da to your computer and use it in GitHub Desktop.
Laravel Timezone model with Sushi
<!-- 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