Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom upload path per field #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Custom upload path per field #2

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 12, 2016

За пример берём Модель User
В модели требуется прописать:

    /**
     * directory under storage_path() OR public_path()
     * @var string||null
     */
    protected $uploadAvatarPath = null;

    /**
     * User constructor.
     */
    public function __construct()
    {
        parent::__construct();
        // i.e.: public/uploads/avatars
        $this->uploadAvatarPath = basename( public_path() ) . '/uploads/avatars/';
        // i.e.: storage/app/public/uploads/avatars
        //$this->uploadAvatarPath = basename( storage_path() ). '/app/public/uploads/avatars/' ;
    }

После чего станет возможным аплоадить файл для каждой колонки таблицы персонально в свой путь.
аватары в аватары, мухи к мухам, а котлеты к котлетам.

Так же добавлена возможность аплоадить в storage_path( "app/public" ), что даёт возможность маскарадить файлы роутом/контроллером.
Это понадобится в ПО закрытого типа, дабы проверить права пользователя в контроллере перед выдачей файла.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants