Skip to content

Commit

Permalink
Add Value to BooleanColumn view
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Oct 25, 2024
1 parent c15c1d1 commit d609cd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Views/Columns/BooleanColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
->withIsBootstrap($this->isBootstrap())
->withSuccessValue($this->getSuccessValue())
->withType($this->getType())
->withValue($value)
->withStatus($this->hasCallback() ? call_user_func($this->getCallback(), $value, $row) : (bool) $value === true);
}
}
14 changes: 14 additions & 0 deletions tests/Views/Columns/BooleanColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ public function test_can_set_toggleable_with_confirm_message(): void
$this->assertTrue($column->hasConfirmMessage());

$this->assertSame('Are you sure?', $column->getConfirmMessage());
}

public function test_can_get_value(): void
{
$column = BooleanColumn::make('Name')->getContents(Pet::find(1));
$this->assertSame($column['value'], 'Cartman');
}

public function test_can_get_is_tailwind(): void
{
$column = BooleanColumn::make('Name')->getContents(Pet::find(1));
$this->assertSame($column['isTailwind'], true);
$this->assertSame($column['isBootstrap'], false);

}

}

0 comments on commit d609cd6

Please sign in to comment.