Skip to content

Commit

Permalink
Update WithSeo.php
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 authored Aug 15, 2024
1 parent 2c7f40d commit a5ad375
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Views/Concerns/WithSeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace Foxws\WireUse\Views\Concerns;

use Artesaos\SEOTools\Facades\SEOMeta;
use Closure;

trait WithSeo
{
public function bootWithSeo(): void
{
SEOMeta::setTitle($this->seoValue('getTitle'));
SEOMeta::setDescription($this->seoValue('getDescription'));
SEOMeta::setRobots($this->seoValue('getRobots'));
SEOMeta::setTitle((string) $this->seoValue('getTitle'));
SEOMeta::setDescription((string) $this->seoValue('getDescription'));
SEOMeta::setRobots((string) $this->seoValue('getRobots'));
}

protected function seoValue(mixed $value, mixed $default = null): mixed
Expand All @@ -20,7 +21,9 @@ protected function seoValue(mixed $value, mixed $default = null): mixed
}

if (method_exists(static::class, $value)) {
return strip_tags($this->$value());
$value = $this->$value();

return is_string($value) ? strip_tags($value) : $value;
}

return $default;
Expand Down

0 comments on commit a5ad375

Please sign in to comment.