matsevh/jeugdwerk-news

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v1.2.6) of this package.

A packages for Jeugdwerk used to merge multiple news sources of an organization into one json

v1.2.6 2024-01-14 10:24 UTC

README

Total Downloads Latest Version License

Jeugdwerk News for Laravel is a package build for Jeugdwerk but usable in other projects. This package will make a json response created with sources you want with th possible option for rss, atom, json feed and a json api.

Get Started

Requires PHP 8.1+

First, install Jeugdwerk News via the Composer package manager:

composer require matsevh/jeugdwerk-news

Start by adding the Jeugdwerk News Service provider into you config/app.php

'providers' => ServiceProvider::defaultProviders()->merge([
    /*
      * Package Service Providers...
      */
    \Matsevh\JeugdwerkNews\NewsServiceProvider::class,

    /*
      * Application Service Providers...
      */
    ...
])->toArray(),

After that you can migrate the news provider table

php artisan migrate

after migrating you can create your news provider(s)

use Matsevh\Jeugdwerk\NewsProviderController

$providerController = new NewsProviderController();
$provider = $providerController->create(
  link_to: 1, // The model id the provider is linked to
  name: 'First Provider', // The name of the provider
  /*
  The allowed and supported types are json and rss
  - rss for rss and atom feeds
  - json for json feeds and api's
  */ 
  type: 'json', 
  link: 'https://www.vrt.be/vrtnieuws/en.rss.articles.xml' // The link/url of the feed
  /*
  The next params are only used when using the type json
  */
  sub: [], // The levels that the will lower when reading the array
  truncate: true, // Truncate the summery to 100 characters
  authentication: [], // Only bearer is supported at the moment leave the array empty when no authentication required
  authentication: [
    'type' => 'bearer',
    'key' => 'Your Bearer Key'
  ], 
  // The field the json fields will turn into the keys are required
  fields: [
    "title" => '', // The news title
    "link" => '', // The link to the article
    "summery" => '', // The summery of the article
    'published' => '' // A Datetime of when the article was published
  ]
));

Usage

Providers

Updating

use Matsevh\Jeugdwerk\NewsProviderController

$providerController = new NewsProviderController();
$provider = $providerController->update(
  providerId: 1 // The provider id you want to update
  // You only have to include the params you want to update
  name: 'Updated Name', // The name of the provider
  truncate: false // Truncate the summery to 100 characters
));

Removing

use Matsevh\Jeugdwerk\NewsProviderController

$providerController = new NewsProviderController();
$provider = $providerController->delete(
  providerId: 1 // The provider id you want to update
));

News

News from one link

use Matsevh\Jeugdwerk\NewsController

$newsController = new NewsController();
$news = $newsController->get(
  link_to: 1 // The link where want all the news from
);

All the news

use Matsevh\Jeugdwerk\NewsController

$newsController = new NewsController();
$news = $newsController->get();

Jeugdwerk News is an open-sourced software licensed under the MIT license.