Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Flatroy committed Oct 14, 2024
1 parent 3830bd8 commit 22a105e
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions app/Filament/Pages/LabelsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,12 @@ public function form(Form $form): Form
->label('Label Height (inches)')
->numeric()
->required()
->default($this->cardHeight)
->rules(['required', 'numeric', 'min:0.1', function($attribute, $value, $fail) {
$availableHeight = $this->pageHeight - $this->pageTopPadding - $this->pageBottomPadding;
if ($value > $availableHeight) {
$fail("The card height must not exceed the available page height.");
}
}]),
->default($this->cardHeight),
TextInput::make('cardWidth')
->label('Label Width (inches)')
->numeric()
->required()
->rules(['required', 'numeric', 'min:0.1', function($attribute, $value, $fail) {
$availableWidth = $this->pageWidth - $this->pageLeftPadding - $this->pageRightPadding;
if ($value > $availableWidth) {
$fail("The card width must not exceed the available page width.");
}
}])
->default($this->cardWidth),
->default($this->cardWidth),
TextInput::make('pageWidth')
->label('Page Width (inches)')
->numeric()
Expand Down Expand Up @@ -136,7 +124,7 @@ public function form(Form $form): Form
])->columns(2);
}

public function generatePages($showNotification = true): void
public function generatePages($showNotification = true)
{
$this->validate();
$this->init();
Expand Down Expand Up @@ -193,10 +181,11 @@ private function calculateGridData()
];
}

$cols = max(1, floor($availablePageWidth / $this->cardWidth));
$rows = max(1, floor($availablePageHeight / $this->cardHeight));
$gapX = $cols > 1 ? ($availablePageWidth - $cols * $this->cardWidth) / ($cols - 1) : 0;
$gapY = $rows > 1 ? ($availablePageHeight - $rows * $this->cardHeight) / ($rows - 1) : 0;
$cols = floor($availablePageWidth / $this->cardWidth);
$rows = floor($availablePageHeight / $this->cardHeight);
$gapX = ($availablePageWidth - $cols * $this->cardWidth) / ($cols - 1);
$gapY = ($this->pageHeight - $rows * $this->cardHeight) / ($rows - 1);

return [
'cols' => $cols,
'rows' => $rows,
Expand Down

0 comments on commit 22a105e

Please sign in to comment.