SeoMetaComponent.php 698 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\View\Components;
  3. use Illuminate\View\Component;
  4. use Meta;
  5. class SeoMetaComponent extends Component
  6. {
  7. public $metas;
  8. /**
  9. * Create a new component instance.
  10. *
  11. * @return void
  12. */
  13. public function __construct($metas)
  14. {
  15. $this->metas = json_decode($metas, true)['Metas'];
  16. }
  17. /**
  18. * Get the view / contents that represent the component.
  19. *
  20. * @return \Illuminate\Contracts\View\View|\Closure|string
  21. */
  22. public function render()
  23. {
  24. foreach ($this->metas ?? [] as $meta) {
  25. Meta::set($meta['Name'], $meta['Content']);
  26. }
  27. return view('components.seo-meta-component');
  28. }
  29. }