oc-social-plugin/components/FacebookPageFeed.php

52 lines
1.1 KiB
PHP

<?php
namespace Zoomyboy\Social\Components;
use Cms\Classes\ComponentBase;
use Illuminate\Support\Collection;
use Zoomyboy\Social\Models\Page;
use Zoomyboy\Social\Models\Post;
class FacebookPageFeed extends ComponentBase
{
public Collection $posts;
public string $logo;
public function componentDetails(): array
{
return [
'name' => 'FacebookFeed',
'description' => 'No description provided yet...',
];
}
public function onRender(): void
{
$this->posts = Post::where('page_id', $this->property('pageid'))
->select('*')
->withIntro()->with('attachments')->latest()->limit(20)
->get();
$this->logo = $this->property('logo');
}
public function defineProperties(): array
{
return [
'pageid' => [
'type' => 'dropdown',
'label' => 'Seite',
],
'logo' => [
'label' => 'Logo',
],
];
}
public function getPageidOptions(): array
{
return Page::get()->pluck('slug', 'id')->toArray();
}
}