Working with articles

On the front end part articles can only be delivered via the front-end Livewire components:
Articles Component defined in app/Http/Livewire/Front/Articles.php
Article Navigation Component defined in app/Http/Livewire/Front/ArticlesNavigation.php
WidgetArticles Component defined in app/Http/Livewire/Front/ArticlesNavigation.php

The only exception is the Article Page itself for which we have the system’s main FrontEndController finding and delivering the article to the view (app/Http/Controllers/FrontEndController@renderArticleHtml()).

Article Components

The articles components all returns instances of \App\Models\Article.php class. In the case of Front\Articles and Widget\Articles those models will be wrapped in a Eloquent Collection, where the Front\ArticleNavigation component will return those models in a simple array. This means that when working with articles from components we’re using the Article class built in methods and properties/relations. For example to get the article url we will use the geturl() method or getUtmUrl() method if we’re in a widget context.

$article->getUrl() 
$article->getUtmUrl()

For an image url we can use:

$article->getBlurredImageUrl()

If we need to display the original image url we can use the hubpage_image_id property (available on all articles) and pass it as param to \App\Models\Image::getUrlStatic($imageId)

\App\Models\Image::getUrlStatic($article->hubpage_image_id)

The above method can also be used with any image id field from any type of data (Category icon or image, Magazine image and so on). Also methods getBlurredImageUrl , getUrl, getUtmUrl are available on the \App\Models\Magazine instances too.

If there’s a case where you need to use the createImageUrl function yourself you might do so whenever you have a valid image url.

createImageUrl(\App\Models\Image::getUrlStatic($article->hubpage_image_id), 'trmblurred', 'thumbnail');
// or
createImageUrl($validImageUrl, 'trmblurred', 'thumbnail');

If article has a magazine it will be available in the $magazine property on the article instance otherwise it will be null. The article categories are available in the $categories property which is Eloquent\Collection holding instances of \App\Models\Category.

Article Page

On article page the article data is in form of array. Everything you need is already there including valid image url (also hubpage_image_id property in case you need to fetch the url yourself and mainImage property with valid image url)