-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1610 from dragomano/option_image
feat: OptionImage
- Loading branch information
Showing
6 changed files
with
287 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoonShine\Support\DTOs\Select; | ||
|
||
use Illuminate\Contracts\Support\Arrayable; | ||
use MoonShine\Support\Enums\ObjectFit; | ||
|
||
final readonly class OptionImage implements Arrayable | ||
{ | ||
public function __construct( | ||
private string $src, | ||
private int $width = 10, | ||
private int $height = 10, | ||
private ObjectFit $objectFit = ObjectFit::COVER, | ||
) { | ||
} | ||
|
||
public function getSrc(): string | ||
{ | ||
return $this->src; | ||
} | ||
|
||
public function getWidth(): int | ||
{ | ||
return $this->width; | ||
} | ||
|
||
public function getHeight(): int | ||
{ | ||
return $this->height; | ||
} | ||
|
||
public function getObjectFit(): string | ||
{ | ||
return $this->objectFit->value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'src' => $this->getSrc(), | ||
'width' => $this->getWidth(), | ||
'height' => $this->getHeight(), | ||
'objectFit' => $this->getObjectFit(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoonShine\Support\Enums; | ||
|
||
enum ObjectFit: string | ||
{ | ||
case CONTAIN = 'contain'; | ||
case COVER = 'cover'; | ||
case FILL = 'fill'; | ||
case NONE = 'none'; | ||
case SCALE_DOWN = 'scale-down'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters