Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ledger.corals.io/Corals/modules/Utility/Traits/Gallery/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ledger.corals.io/Corals/modules/Utility/Traits/Gallery/ServiceHasGalleryTrait.php
<?php


namespace Corals\Modules\Utility\Traits\Gallery;


trait ServiceHasGalleryTrait
{
    public function handleGalleryInputs($request, $galleryModel)
    {
        $galleryInputs = $request->only(['gallery_new', 'gallery_deleted', 'gallery_favorite']);

        $deleted = [];

        foreach (explode(',', data_get($galleryInputs, 'gallery_deleted')) as $fileHash) {
            if (!$fileHash) {
                continue;
            }
            $files = glob(public_path("tmp/{$fileHash}_tmp_*"));
            foreach ($files as $file) {
                $deleted[] = $fileHash;
                @unlink($file);
            }
        }

        foreach (explode(',', data_get($galleryInputs, 'gallery_new')) as $fileHash) {
            if (!$fileHash || in_array($fileHash, $deleted)) {
                continue;
            }

            $files = glob(public_path("tmp/{$fileHash}_tmp_*"));

            foreach ($files as $file) {
                $properties = [
                    'root' => 'user_' . user()->hashed_id,
                ];

                if ($galleryInputs['gallery_favorite'] == $fileHash) {
                    $properties['featured'] = true;
                }

                $galleryModel->addMedia($file)
                    ->withCustomProperties($properties)
                    ->toMediaCollection($galleryModel->galleryMediaCollection);
            }
        }
    }
}

Spamworldpro Mini