Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMB Details & Hours #44 #55

Merged
merged 37 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f1a6381
Timezones #42
Mar 1, 2021
35a0502
Update location of key model
drewroberts Mar 1, 2021
26387cf
Fix styling
drewroberts Mar 1, 2021
74a1269
Merge branch 'main' into chx2/feature/refactored-models
drewroberts Mar 2, 2021
14d315c
Add timezone relationship to market #40 #41
drewroberts Mar 2, 2021
34063bc
Add timezone relationship to location #40 #42
drewroberts Mar 2, 2021
1c485ef
Timezone Seeder Migrations #40
Mar 2, 2021
83dd73e
Register Timezone Policy #40
chx2 Mar 2, 2021
d448fdf
Fix styling
chx2 Mar 2, 2021
1eb6cdb
Merge branch 'main' into chx2/feature/refactored-models
drewroberts Mar 4, 2021
7efafbc
Remove timezones
drewroberts Mar 4, 2021
e2f9981
Remove timezone policy registration
drewroberts Mar 4, 2021
d4ca1ff
Profile Links #52
chx2 Mar 4, 2021
1ed7dac
Fix migration for Profile Links #52
chx2 Mar 4, 2021
da5de74
GMB Details #44
chx2 Mar 4, 2021
f10a566
GMB Hours #44
chx2 Mar 4, 2021
f6f72a3
Fix styling
chx2 Mar 4, 2021
44b8a48
GMB Hours Permissions #44
chx2 Mar 4, 2021
a8b904c
Merge remote-tracking branch 'origin/chx2/feature/refactored-models' …
chx2 Mar 4, 2021
9629bf6
Nova Resources
chx2 Mar 5, 2021
14d733f
Bump support dependency
drewroberts Mar 6, 2021
f9d5ee8
Merge branch 'main' into chx2/feature/refactored-models
drewroberts Mar 6, 2021
037778d
Require tipoff addresses package
drewroberts Mar 6, 2021
c5a113a
Update market factory to include new timezone #40
drewroberts Mar 6, 2021
a22dfdd
Include new timezone in location factory #40
drewroberts Mar 6, 2021
312f42d
Update permissions migration
drewroberts Mar 6, 2021
3abd259
Update permissions migration test #2
drewroberts Mar 6, 2021
faff54b
Remove create & update permissions for gmb data #44
drewroberts Mar 6, 2021
57ac295
Remove profile links from this package #52
drewroberts Mar 6, 2021
6d78f9a
Run package service providers of dependencies
drewroberts Mar 6, 2021
6779586
Fix styling
drewroberts Mar 6, 2021
1fda663
Bump support package
drewroberts Mar 6, 2021
07f4716
Remove factory doc blocks
drewroberts Mar 6, 2021
8ce43da
Update timezone autosave on market & location models #40
drewroberts Mar 6, 2021
b2b7104
Fix styling
drewroberts Mar 6, 2021
82db62e
Disable default timestamp inserts
chx2 Mar 6, 2021
9c95f55
Bump to new release of seo package
drewroberts Mar 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"require": {
"php": "^7.4|^8.0",
"drewroberts/media": "^3.2.2",
"tipoff/addresses": "^2.0.0",
"tipoff/authorization": "^2.3.1",
"tipoff/seo": "^1.0.8",
"tipoff/support": "^1.5.7"
"tipoff/seo": "^2.0.0",
"tipoff/support": "^1.5.8"
},
"require-dev": {
"tipoff/test-support": "^1.2.0"
Expand Down
33 changes: 33 additions & 0 deletions database/factories/GmbDetailFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Tipoff\Locations\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Date;
use Tipoff\Locations\Models\GmbDetail;
use Tipoff\Locations\Models\Location;

class GmbDetailFactory extends Factory
{
protected $model = GmbDetail::class;

public function definition()
{
return [
'name' => $this->faker->name,
'opened_at' => $this->faker->date('Y-m-d'),
'address' => $this->faker->address,
'address2' => $this->faker->address,
'city' => $this->faker->city,
'state' => $this->faker->state,
'zip' => $this->faker->postcode,
'phone' => $this->faker->phoneNumber,
'latitude' => $this->faker->latitude,
'longitude' => $this->faker->longitude,
'location_id' => Location::factory()->create()->id,
'created_at' => Date::now()
];
}
}
37 changes: 37 additions & 0 deletions database/factories/GmbHourFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Tipoff\Locations\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Date;
use Tipoff\Locations\Models\GmbHour;
use Tipoff\Locations\Models\Location;

class GmbHourFactory extends Factory
{
protected $model = GmbHour::class;

public function definition()
{
return [
'monday_open' => $this->faker->text,
'monday_close' => $this->faker->text,
'tuesday_open' => $this->faker->text,
'tuesday_close' => $this->faker->text,
'wednesday_open' => $this->faker->text,
'wednesday_close' => $this->faker->text,
'thursday_open' => $this->faker->text,
'thursday_close' => $this->faker->text,
'friday_open' => $this->faker->text,
'friday_close' => $this->faker->text,
'saturday_open' => $this->faker->text,
'saturday_close' => $this->faker->text,
'sunday_open' => $this->faker->text,
'sunday_close' => $this->faker->text,
'location_id' => Location::factory()->create()->id,
'created_at' => Date::now()
];
}
}
12 changes: 1 addition & 11 deletions database/factories/LocationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,8 @@

class LocationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Location::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$city = $this->faker->city;
Expand All @@ -31,8 +21,8 @@ public function definition()
'name' => $city,
'slug' => Str::slug($city),
'title_part' => $city,
'timezone' => $this->faker->timezone,
'market_id' => randomOrCreate(Market::class),
'timezone_id' => randomOrCreate(app('timezone')),
'creator_id' => randomOrCreate(app('user')),
'updater_id' => randomOrCreate(app('user'))
];
Expand Down
12 changes: 1 addition & 11 deletions database/factories/MarketFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,8 @@

class MarketFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Market::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$city = $this->faker->city;
Expand All @@ -31,9 +21,9 @@ public function definition()
'name' => $city,
'title' => $city,
'state' => $this->faker->stateAbbr,
'timezone' => 'EST',
'content' => $this->faker->sentences(3, true),
'entered_at' => $this->faker->date(),
'timezone_id' => randomOrCreate(app('timezone')),
'creator_id' => randomOrCreate(app('user')),
'updater_id' => randomOrCreate(app('user')),
];
Expand Down
22 changes: 0 additions & 22 deletions database/migrations/2014_01_01_100000_create_timezones_table.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function up()
$table->string('name')->unique();
$table->string('title')->unique(); // Market Title for Display. Used publicly.
$table->string('state'); // Just the 2-digit abbreviation.
$table->string('timezone');
$table->foreignIdFor(app('timezone'));
$table->text('content')->nullable(); // Market specific content. Written in Markdown.
$table->date('entered_at'); // Date first location opened in the market.
$table->date('closed_at')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
$table->string('name')->unique(); // Internal reference name
$table->string('abbreviation', 4)->unique(); // 3 digit abbreviation (all caps) for location. Option to add 4th digit character if necessary.
$table->string('title_part')->nullable(); // For when have more than one location in a market, this is used to generate formal title.
$table->string('timezone'); // Informal symbol such as EST or CST
$table->foreignIdFor(app('timezone'));
$table->foreignIdFor(Market::class);
$table->foreignIdFor(app('user'), 'manager_id')->nullable();
$table->string('contact_email');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public function up()
'view locations',
'create locations',
'update locations',
'delete locations',
'view markets',
'create markets',
'update markets',
'delete markets'
];
'view gmb details',
'view gmb hours',
];

$this->createPermissions($permissions);
}
Expand Down
6 changes: 6 additions & 0 deletions src/LocationsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
namespace Tipoff\Locations;

use Tipoff\Locations\Commands\SyncLocations;
use Tipoff\Locations\Models\GmbDetail;
use Tipoff\Locations\Models\GmbHour;
use Tipoff\Locations\Models\Location;
use Tipoff\Locations\Models\Market;
use Tipoff\Locations\Policies\GmbDetailPolicy;
use Tipoff\Locations\Policies\GmbHourPolicy;
use Tipoff\Locations\Policies\LocationPolicy;
use Tipoff\Locations\Policies\MarketPolicy;
use Tipoff\Support\TipoffPackage;
Expand All @@ -18,6 +22,8 @@ public function configureTipoffPackage(TipoffPackage $package): void
{
$package
->hasPolicies([
GmbDetail::class => GmbDetailPolicy::class,
GmbHour::class => GmbHourPolicy::class,
Location::class => LocationPolicy::class,
Market::class => MarketPolicy::class,
])
Expand Down
29 changes: 29 additions & 0 deletions src/Models/GmbDetail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Tipoff\Locations\Models;

use Tipoff\Support\Models\BaseModel;
use Tipoff\Support\Traits\HasCreator;
use Tipoff\Support\Traits\HasPackageFactory;
use Tipoff\Support\Traits\HasUpdater;

class GmbDetail extends BaseModel
{
use HasPackageFactory;
use HasCreator;
use HasUpdater;

public $timestamps = false;

public function location()
{
return $this->belongsTo(Location::class);
}

public function webpage()
{
return $this->belongsTo(app('webpage'));
}
}
24 changes: 24 additions & 0 deletions src/Models/GmbHour.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Tipoff\Locations\Models;

use Tipoff\Support\Models\BaseModel;
use Tipoff\Support\Traits\HasCreator;
use Tipoff\Support\Traits\HasPackageFactory;
use Tipoff\Support\Traits\HasUpdater;

class GmbHour extends BaseModel
{
use HasPackageFactory;
use HasCreator;
use HasUpdater;

public $timestamps = false;

public function location()
{
return $this->belongsTo(Location::class);
}
}
9 changes: 5 additions & 4 deletions src/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ protected static function boot()
if (empty($location->market_id)) {
throw new \Exception('A location must be in a market.');
}
if (empty($location->timezone)) {
$location->timezone = 'EST';
if (empty($location->timezone_id)) {
// @todo refactor to fetch EST timezone and save it here
$location->timezone_id = 1;
}
if (empty($location->contact_email)) {
$location->contact_email = $location->slug . '@thegreatescaperoom.com';
Expand Down Expand Up @@ -288,7 +289,7 @@ public function getRevenueBookedYesterdayAttribute()
$query->where('location_id', $this->id);
})->sum('amount')
+
$bookingModel::yesterday()
$bookingModel::yesterday()
->whereHas('order', function (Builder $query) {
$query->where('location_id', $this->id);
})->sum('total_fees')) / 100, 2);
Expand All @@ -315,7 +316,7 @@ public function getRevenueBookedLastWeekAttribute()
$query->where('location_id', $this->id);
})->sum('amount')
+
$bookingModel::week()
$bookingModel::week()
->whereHas('order', function (Builder $query) {
$query->where('location_id', $this->id);
})->sum('total_fees')) / 100, 2);
Expand Down
7 changes: 4 additions & 3 deletions src/Models/Market.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ protected static function boot()
if (empty($market->entered_at)) {
$market->entered_at = '2016-01-01';
}
if (empty($market->timezone)) {
$market->timezone = 'EST';
if (empty($market->timezone_id)) {
// @todo refactor to fetch EST timezone and save it here
$market->timezone_id = 1;
}
});

Expand Down Expand Up @@ -158,7 +159,7 @@ public function getDescriptionAttribute()

$rooms = $roomModel::whereIn('location_id', $locations->pluck('id'))->whereNull('closed_at')->get();

return $this->title.' has '.$rooms->count().' different escape rooms and offers private escape games for groups & parties. Book your escape room today!';
return $this->title . ' has ' . $rooms->count() . ' different escape rooms and offers private escape games for groups & parties. Book your escape room today!';
}

public function findAllThemes()
Expand Down
2 changes: 1 addition & 1 deletion src/Nova/Filters/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Tippoff\Locations\Nova\Filters;
namespace Tipoff\Locations\Nova\Filters;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
Expand Down
49 changes: 49 additions & 0 deletions src/Policies/GmbDetailPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Tipoff\Locations\Policies;

use Illuminate\Auth\Access\HandlesAuthorization;
use Tipoff\Locations\Models\GmbDetail;
use Tipoff\Support\Contracts\Models\UserInterface;

class GmbDetailPolicy
{
use HandlesAuthorization;

public function viewAny(UserInterface $user): bool
{
return $user->hasPermissionTo('view gmb details') ? true : false;
}

public function view(UserInterface $user, GmbDetail $gmb_detail): bool
{
return $user->hasPermissionTo('view gmb details') ? true : false;
}

public function create(UserInterface $user): bool
{
return false;
}

public function update(UserInterface $user, GmbDetail $gmb_detail): bool
{
return false;
}

public function delete(UserInterface $user, GmbDetail $gmb_detail): bool
{
return false;
}

public function restore(UserInterface $user, GmbDetail $gmb_detail): bool
{
return false;
}

public function forceDelete(UserInterface $user, GmbDetail $gmb_detail): bool
{
return false;
}
}
Loading