4 Commits
2 changed files with 29 additions and 5 deletions

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
## How to install
1. Install the package `composer require mathiaspalmqvist/laravel-cision-feed`
2. add the cision company slug to `LARAVEL_CISION_FEED_SLUG` at your env
## Functions
`LaravelCisionFeed::all();`
Returns everyting from the feed.
`LaravelCisionFeed::press();`
Returns all press releases from the feed.
`LaravelCisionFeed::financial();`
Returns all financial reports from the feed.
`LaravelCisionFeed::news();`
Returns all news from the feed.
`LaravelCisionFeed::media();`
Returns all media from the feed.
+9 -5
View File
@@ -19,7 +19,7 @@ class LaravelCisionFeed
return false;
}
return self::parse($request->body());
return self::parse($request->body(), $page);
}
/**
@@ -41,7 +41,7 @@ class LaravelCisionFeed
* @param int $page
* @return array|false
*/
public static function financial(int $page = 1): bool|array
public static function financial(int $page = 1): bool|array
{
$request = self::request($page, 'Financial');
@@ -108,9 +108,10 @@ class LaravelCisionFeed
/**
* @param string|null $data
* @return array|false
* @param int $page
* @return bool|array
*/
private static function parse(string $data = null): bool|array
private static function parse(string $data = null, int $page = 1): bool|array
{
if ($data === null) {
return false;
@@ -127,7 +128,7 @@ class LaravelCisionFeed
$return = [];
foreach ($rows['channel']['item'] as $row) {
$return[] = [
$return['items'][] = [
'guid' => $row['guid'],
'title' => $row['title'],
'description' => $row['description'],
@@ -136,6 +137,9 @@ class LaravelCisionFeed
];
}
$return['previous_page'] = $page > 1 ? $page-- : false;
$return['next_page'] = count( $rows['channel']['item'] ) === 24 ? ++$page : false;
return $return;
}
}