Последняя версия с сервера прошлого разработчика

This commit is contained in:
2025-07-10 04:35:51 +00:00
commit c731570032
1174 changed files with 134314 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
<?php
namespace App\Domain\Feeds\Service;
use App\Domain\Feeds\Models\Feed;
use App\Domain\Feeds\Enums\CollectionMediaEnum;
class FeedMediaTransform
{
public $feed;
public $type;
public $typeUrl = 'web';
public $collection_name;
public function __construct(Feed $feed)
{
$this->feed = $feed;
$this->type = $feed->type;
}
public function getFullPath()
{
$this->typeUrl = 'disk';
return $this;
}
public function paid()
{
return $this->addCollectionMediaName(CollectionMediaEnum::PAID());
}
public function default()
{
return $this->addCollectionMediaName(CollectionMediaEnum::COMMON());
}
public function addCollectionMediaName($collection_name)
{
$this->collection_name = $collection_name;
return $this;
}
public function spot()
{
if($this->type === 'images'){
return $this->images();
}
if($this->type === 'videos'){
return $this->videos();
}
if($this->type === 'musics'){
return $this->musics();
}
}
public function videos()
{
$collection = [];
$medias = $this->feed->getMedia($this->collection_name);
$medias->each(function ($item) use (&$collection) {
$collection[] = [
'url' => $this->typeUrl === 'web' ? $item->getFullUrl() : $item->getPath(),
'id' => $item->id,
];
});
return [
'preview' => $this->getPreview(),
'medias' => $collection,
];
}
public function images()
{
$collection = [];
$medias = $this->feed->getMedia($this->collection_name);
$medias->each(function ($item) use (&$collection) {
$collection[] = [
'url' => $this->typeUrl === 'web' ? $item->getFullUrl() : $item->getPath(),
'id' => $item->id,
];
});
return [
'preview' => $this->getPreview(),
'medias' => $collection,
];
}
public function musics()
{
$collection = [];
$medias = $this->feed->getMedia($this->collection_name);
$medias->each(function ($item) use (&$collection) {
$collection[] = [
'url' => $this->typeUrl === 'web' ? $item->getFullUrl() : $item->getPath(),
'name' => $item->name,
'playing' => false,
'liked' => $item->likes_count ?? false,
'time' => $item->getCustomProperty('time'),
'id' => $item->id,
];
});
return [
'preview' => $this->getPreview(),
'medias' => $collection,
];
}
public function getPreview($type = 0)
{
if($this->type === 'images'){
$img_preview = $this->feed->getMedia($this->collection_name)->first();
if($img_preview){
if($type){
return $img_preview;
}
return $img_preview->getFullUrl();
}
}
$preview = $this->feed->getMedia(CollectionMediaEnum::PREVIEW());
if($type){
return $preview->count() ? $preview->first() : null;
}
return $preview->count() ? $preview->first()->getFullUrl() : null;
}
public function getPreviewObject()
{
$preview = $this->getPreview(1);
if($preview){
return [ 'id'=> $preview->id, 'url' => $preview->getFullUrl() ];
}
return null;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Domain\Feeds\Service;
use DB;
class LiveFeed
{
public static function addBySub($user)
{
$userID = $user->id;
$userFeeds = $user->feeds()->pluck('created_at', 'id')->transform(function ($item) {
return ['times' => $item->getTimestamp()];
})->toArray();
$add_posts = [];
foreach ($userFeeds as $feedID => $userFeed) {
$add_posts[] = [
'feed_id' => $feedID,
'user_id' => auth()->user()->id,
'home_user_id' => $userID,
'times' => $userFeed['times'],
];
}
DB::table('users_live_feeds')->insertOrIgnore($add_posts);
}
public static function removeBySub($user)
{
$userID = $user->id;
DB::table('users_live_feeds')
->where('home_user_id', $userID)
->where('user_id', auth()->user()->id)
->delete();
}
}