-
-
Notifications
You must be signed in to change notification settings - Fork 12
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 #5 from adrianthedev/feature/add-custom-avatar-in-…
…search feature: add custom avatar ability in search
- Loading branch information
Showing
4 changed files
with
104 additions
and
66 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
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,24 @@ | ||
<?php | ||
|
||
namespace Chaseconey\ExternalImage; | ||
|
||
use Laravel\Nova\Contracts\Cover; | ||
|
||
class ExternalImageAsAvatar extends ExternalImageBase implements Cover | ||
{ | ||
/** | ||
* Resolve the thumbnail URL for the field. | ||
* | ||
* @return string|null | ||
*/ | ||
public function resolveThumbnailUrl() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
public function isRounded() | ||
{ | ||
return $this->rounded; | ||
} | ||
|
||
} |
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,74 @@ | ||
<?php | ||
|
||
namespace Chaseconey\ExternalImage; | ||
|
||
use Laravel\Nova\Fields\Field; | ||
|
||
class ExternalImageBase extends Field | ||
{ | ||
protected $rounded = false; | ||
|
||
/** | ||
* The field's component. | ||
* | ||
* @var string | ||
*/ | ||
public $component = 'external-image'; | ||
|
||
/** | ||
* | ||
* Add prefix to the image string provided | ||
* | ||
* @param string $prefix | ||
* @return ExternalImage | ||
*/ | ||
public function prefix(string $prefix) | ||
{ | ||
return $this->withMeta(['prefix' => $prefix]); | ||
} | ||
|
||
/** | ||
* Set the image with avatar-like style | ||
* | ||
* @return $this | ||
*/ | ||
public function avatar() | ||
{ | ||
$this->rounded = true; | ||
|
||
return $this->width(42)->height(42)->radius(99); | ||
} | ||
|
||
/** | ||
* Set the width of the image | ||
* | ||
* @param int $width | ||
* @return $this | ||
*/ | ||
public function width(int $width) | ||
{ | ||
return $this->withMeta(['width' => $width]); | ||
} | ||
|
||
/** | ||
* Set the height of the image | ||
* | ||
* @param int $height | ||
* @return $this | ||
*/ | ||
public function height(int $height) | ||
{ | ||
return $this->withMeta(['height' => $height]); | ||
} | ||
|
||
/** | ||
* Set the border-radius of the image | ||
* | ||
* @param int $radius | ||
* @return $this | ||
*/ | ||
public function radius(int $radius) | ||
{ | ||
return $this->withMeta(['borderRadius' => $radius]); | ||
} | ||
} |