Skip to content

Commit

Permalink
Merge pull request #394 from timiajayi/viewtimezones
Browse files Browse the repository at this point in the history
feat: get list of timezones
  • Loading branch information
timiajayi authored Aug 7, 2024
2 parents 8c34f9f + 449382e commit 49bdbb4
Show file tree
Hide file tree
Showing 27 changed files with 45,250 additions and 2,488 deletions.
6,337 changes: 5,832 additions & 505 deletions .scribe/endpoints.cache/00.yaml

Large diffs are not rendered by default.

6,335 changes: 5,831 additions & 504 deletions .scribe/endpoints/00.yaml

Large diffs are not rendered by default.

Empty file added [
Empty file.
21 changes: 21 additions & 0 deletions app/Http/Controllers/Api/V1/TimezoneController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Controllers\Api\V1;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Timezone;

class TimezoneController extends Controller
{
public function index()
{
$timezones = Timezone::all();
return response()->json([
'status' => 'success',
'message' => 'Timezones retrieved successfully',
'data' => $timezones
]);
}

}
6 changes: 4 additions & 2 deletions app/Models/Timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class Timezone extends Model

protected $guarded = [];

// Set the key type to string
protected $keyType = 'string';

// Disable auto-incrementing IDs
public $incrementing = false;
protected $casts = [
'offset' => 'string',
];


public function preferences()
{
Expand Down
Empty file added can
Empty file.
20 changes: 20 additions & 0 deletions database/factories/TimezoneFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Database\Factories;

use App\Models\Timezone;
use Illuminate\Database\Eloquent\Factories\Factory;

class TimezoneFactory extends Factory
{
protected $model = Timezone::class;

public function definition()
{
return [
'name' => $this->faker->timezone,
'offset' => (string) $this->faker->numberBetween(-43200, 50400),

];
}
}
2 changes: 2 additions & 0 deletions database/factories/UserSubscriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Organisation;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\UserSubscription>
Expand All @@ -32,6 +33,7 @@ public function definition(): array
return $now->addYear();
}
},
'org_id' => Organisation::inRandomOrder()->first()->id ?? Organisation::factory(),
];
}
}
3 changes: 2 additions & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function run(): void
UserNotificationSeeder::class,
NotificationSettingSeeder::class,
OrderSeeder::class,
SqueezePageSeeder::class
SqueezePageSeeder::class,
TimezoneSeeder::class,
]);

$this->call([
Expand Down
22 changes: 22 additions & 0 deletions database/seeders/TimezoneSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Timezone;
use DateTimeZone;

class TimezoneSeeder extends Seeder
{
public function run()
{
$timezones = DateTimeZone::listIdentifiers();

foreach ($timezones as $timezone) {
Timezone::create([
'name' => $timezone,
'offset' => (new DateTimeZone($timezone))->getOffset(new \DateTime()),
]);
}
}
}
Binary file added public/uploads/1723005492.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/1723005641.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/1723005793.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/1723006364.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/1723006536.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/1723006580.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/1723007660.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 49bdbb4

Please sign in to comment.