PHP code example of tomatophp / filament-cms-github
1. Go to this page and download the library: Download tomatophp/filament-cms-github library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tomatophp / filament-cms-github example snippets
use TomatoPHP\FilamentCmsGithub\FilamentCmsGithubPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugin(FilamentCmsGithubPlugin::make());
}
use TomatoPHP\FilamentCmsGithub\Services\GitHubService;
use TomatoPHP\FilamentCms\Models\Post;
$service = app(GitHubService::class);
$post = Post::find(1);
$success = $service->refreshPost($post);
use TomatoPHP\FilamentCmsGithub\Services\GitHubService;
$service = app(GitHubService::class);
$count = $service->refreshAllPosts(); // Returns number of posts refreshed
use TomatoPHP\FilamentCmsGithub\Filament\Actions\GithubImportAction;
// In your resource
protected function getHeaderActions(): array
{
return [
GithubImportAction::make(),
];
}
use TomatoPHP\FilamentCmsGithub\Filament\Actions\GithubRefreshAction;
protected function getHeaderActions(): array
{
return [
GithubRefreshAction::make(),
];
}
use TomatoPHP\FilamentCmsGithub\Jobs\GitHubMetaRefreshJob;
dispatch(new GitHubMetaRefreshJob);
use TomatoPHP\FilamentCms\Events\PostCreated;
use Illuminate\Support\Facades\Event;
Event::listen(PostCreated::class, function ($event) {
$post = $event->model;
// Custom processing here
if ($post->type === 'open-source') {
// Do something with imported repository
}
});
use Illuminate\Support\Facades\Notification;
use TomatoPHP\FilamentCmsGithub\Jobs\GitHubMetaGetterJob;
class CustomNotificationHandler
{
public function handle(GitHubMetaGetterJob $job)
{
// Custom notification logic
}
}