Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
14 changes: 12 additions & 2 deletions src/Models/RecurringSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ class RecurringSchedule extends BaseModel
'expires_at' => 'date',
];

public $days = [
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
];

public static function boot()
{
parent::boot();
Expand Down Expand Up @@ -88,9 +98,9 @@ public function room()
return $this->belongsTo(app('room'));
}

public function rate()
public function escaperoom_rate()
{
return $this->belongsTo(app('escaperoom_rate'));
return $this->belongsTo(app('escaperoom_rate'), 'escaperoom_rate_id');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Nova/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
ID::make()->sortable(),
nova('escaperoom_slot') ? BelongsTo::make('EscaperoomSlot', 'slot', nova('slot'))->sortable() : null,
nova('escaperoom_slot') ? BelongsTo::make('EscaperoomSlot', 'slot', nova('escaperoom_slot'))->sortable() : null,
Number::make('Participants')->sortable(),
Date::make('Created', 'created_at')->sortable(),
// May include type here was a custom badge like on Feedback
Expand All @@ -67,7 +67,7 @@ public function fields(Request $request)
{
return array_filter([

nova('escaperoom_slot') ? BelongsTo::make('EscaperoomSlot', 'slot', nova('slot'))->hideWhenUpdating()->searchable() : null,
nova('escaperoom_slot') ? BelongsTo::make('EscaperoomSlot', 'slot', nova('escaperoom_slot'))->hideWhenUpdating()->searchable() : null,
Number::make('Participants')->hideWhenCreating()->min(0)->max(20)->step(1),
Select::make('Type')->options([
'staffing' => 'Staffing Availability or Issue',
Expand Down
14 changes: 12 additions & 2 deletions src/Nova/EscaperoomSlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Laravel\Nova\Fields\HasOne;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\MorphMany;
use Laravel\Nova\Fields\MorphTo;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
Expand Down Expand Up @@ -58,6 +59,7 @@ public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
ID::make()->sortable(),
Text::make('Slot Number')->sortable(),
Text::make('Room', 'room.id', function () {
return $this->resource->room->name;
})->sortable(),
Expand All @@ -79,10 +81,18 @@ public function fields(Request $request)
return $this->resource->formatted_start;
})->exceptOnForms(),
DateTime::make('Start At')->required(),
nova('rate') ? BelongsTo::make('Rate', 'rate', nova('rate'))->hideWhenCreating()->nullable() : null,
MorphTo::make('schedule')->types(array_filter([
nova('user'),
nova('contact'),
nova('customer'),
nova('order'),
nova('booking'),
nova('game'),
nova('block'),
nova('slot'),
Comment on lines +85 to +92
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like the proper list for this morph. The comment was only showing proper technique, not the desired set of objects.

Copy link
Copy Markdown
Contributor Author

@wolfrednicolas wolfrednicolas Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drewroberts could you give me the nova resources related to schedule morph relation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one resolved?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @joshtorres is missing the list of objects related to that morph relation, different than that is ready to merge

]))->nullable(),
nova('supervision') ? BelongsTo::make('Supervision', 'supervision', nova('supervision'))->hideWhenCreating()->nullable() : null,
new Panel('Participant Details', $this->participantFields()),
nova('booking') ? HasMany::make('Bookings', 'bookings', nova('booking')) : null,
nova('block') ? HasMany::make('Blocks', 'blocks', nova('block')) : null,
nova('note') ? MorphMany::make('Notes', 'notes', nova('note')) : null,
nova('game') ? HasOne::make('Game', 'game', nova('game'))->nullable()->exceptOnForms() : null,
Expand Down
53 changes: 25 additions & 28 deletions src/Nova/RecurringSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@ class RecurringSchedule extends BaseResource

/** @psalm-suppress UndefinedClass */
protected array $filterClassList = [
\Tipoff\EscapeRoom\Nova\Filters\Room::class,
\Tipoff\EscapeRoom\Nova\Filters\RoomLocation::class,
\Tipoff\EscapeRoom\Filters\Room::class,
\Tipoff\EscapeRoom\Filters\RoomLocation::class,
Comment thread
wolfrednicolas marked this conversation as resolved.
Outdated
];

public static function indexQuery(NovaRequest $request, $query)
{
if ($request->user()->hasPermissionTo('all locations')) {
if ($request->user()->hasRole([
'Admin',
'Owner',
'Accountant',
'Executive',
'Reservation Manager',
'Reservationist',
])) {
return $query;
}

return $query->select('recurring_schedules.*')
->join('rooms', 'rooms.id', '=', 'recurring_schedules.room_id');
/** @psalm-suppress UndefinedMagicMethod */
return $request->withOrdering($request->withFilters(
$query->select('recurring_schedules.*')
->join('rooms', 'rooms.id', '=', 'recurring_schedules.room_id')
));
Comment thread
wolfrednicolas marked this conversation as resolved.
Outdated
}

public static $group = 'Operations Scheduler';
Expand All @@ -50,39 +60,26 @@ public function fieldsForIndex(NovaRequest $request)
return array_filter([
ID::make()->sortable(),
Text::make('Room', 'rooms.id', function () {
return $this->resource->room->name;
return $this->room->name;
})->sortable(),
Select::make('Day')->options([
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
])->displayUsingLabels()->sortable(),
TimeField::make('Time')->withTwelveHourTime()->sortable(),
Text::make('Rate', 'rate.id', function () {
return $this->resource->rate->name ?? null;
Text::make('Escaperoom Rate', 'rate', function () {
return $this->escaperoom_rate->name;
})->sortable(),
Select::make('Day')->options($this->days)->displayUsingLabels()->sortable(),
TimeField::make('Time')->withTwelveHourTime()->sortable(),
]);
}

public function fields(Request $request)
{
return array_filter([
nova('room') ? BelongsTo::make('Room', 'room', nova('room'))->required() : null,
Select::make('Day of the Week', 'day')->options([
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
])->required(),
Select::make('Day of the Week', 'day')->options($this->days)->required(),
Text::make('Day of the Week', 'day.week', function () {
return $this->days[$this->day];
})->sortable()->onlyOnDetail(),
TimeField::make('Time')->withTwelveHourTime()->required(),
nova('rate') ? BelongsTo::make('Rate', 'rate', nova('rate'))->hideWhenCreating()->nullable() : null,
nova('escaperoom_rate') ? BelongsTo::make('Escaperoom Rate', 'escaperoom_rate', nova('escaperoom_rate'))->hideWhenCreating()->nullable() : null,

new Panel('Optional Date Fields', $this->dateFields()),

Expand Down