File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/WebinarTags/WebinarTagService.php
<?php
namespace App\Komma\WebinarTags;
use App\Komma\Base\Service;
use Illuminate\Database\Eloquent\Collection;
final class WebinarTagService extends Service
{
public function __construct()
{
parent::__construct();
}
/**
* return all webinar tags with webinars
*
* @return Collection
*/
public function getAllWebinarTags(): Collection
{
$tags = $this->site
->webinarTags()
->with('translation', 'webinars')
->where('active', '=', 1)
->where('lft', '!=', 1)
->orderBy('lft', 'desc')
->get();
foreach ($tags as $tag) {
if ($tag->id !== 2) {
$tag->webinars = $tag->webinars->sortBy('lft');
}
if ($tag->id === 2) {
$tag->webinars = $tag->webinars->sortByDesc(function ($obj, $key) {
return $obj->created_at->getTimeStamp();
});
}
}
return $tags;
}
}