{"id":355560,"date":"2024-05-20T23:11:16","date_gmt":"2024-05-20T23:11:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=355560"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=355560","title":{"rendered":"<span>\u041d\u0435\u043e\u0440\u0442\u043e\u0434\u043e\u043a\u0441\u0430\u043b\u044c\u043d\u044b\u0439 Eloquent. \u0427\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0412\u044b \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/762598\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c<\/a>, \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c!<\/p>\n<h2>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/h2>\n<p>\u042d\u0442\u043e \u043a\u0440\u0430\u0442\u043a\u0430\u044f, \u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u0430\u044f (\u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435) \u0433\u043b\u0430\u0432\u0430. \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0412\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0437\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0436\u0430\u0434\u043d\u044b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0435 \u0443\u0447\u0430\u0441\u0442\u043a\u0438 \u043a\u043e\u0434\u0430. \u0425\u043e\u0442\u044f \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438\u0437-\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0430\u043d\u0442\u0430\u0441\u043c\u0430\u0433\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u00a0<a href=\"https:\/\/github.com\/spatie\/laravel-medialibrary\" rel=\"noopener noreferrer nofollow\">laravel-medialibrary\u00a0<\/a>\u043e\u0442 Spatie.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435, \u0447\u0442\u043e \u0443 \u0412\u0430\u0441 \u0435\u0441\u0442\u044c 10 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041a\u0430\u0436\u0434\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 <code>MediaCollections<\/code> \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0432\u044c\u044e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u041f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0442.\u0434. \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0449\u0438\u043c (\u0434\u0430 \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435). \u041f\u0430\u043a\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043c\u0435\u0434\u0438\u0430-\u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u043e\u043c, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u043c \u0432\u0441\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0434\u0438\u0430-\u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043c\u0430\u0433\u0438\u044e <code>Collection<\/code> \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u043b\u044f \u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0416\u0430\u0434\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432\u0441\u0435\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u0433\u0434\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043a\u0443\u0447\u0435\u0439 <code>MediaCollections<\/code>. \u0412\u0435\u0434\u044c, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430 \u043d\u0435\u0439 &#8212; \u044d\u0442\u043e \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u0435\u0432\u044c\u044e. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre><code class=\"php\">public function index(): View {     $products = Product::with([         'categories',         'media' => static function (MorphMany $query) {             $query->where('collection_name', 'thumbnail')         },         'variant.media' => static function (MorphMany $query) {             $query->where('collection_name', 'thumbnail')         },     ])->tap(new Available())->get();      return $this->view->make('products.index', compact('products')); }<\/code><\/pre>\n<p>\u0425\u043e\u0442\u044f \u044d\u0442\u043e \u0438 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437. \u0424\u0443! \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u043e \u0431\u0435\u0437\u0443\u043c\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 &#171;\u0436\u0430\u0434\u043d\u043e&#187; \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c. \u041f\u043e\u043d\u044f\u043b\u0438? \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>LoadThumbnail<\/code>:<\/p>\n<pre><code class=\"php\">final readonly class LoadThumbnail implements Arrayable {     public function __invoke(MorphMany $query): void     {         $query->where('collection_name', 'thumbnail');     }      public function toArray(): array     {         return ['media' => $this];     } }<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0435\u0433\u043e:<\/p>\n<pre><code class=\"php\">public function index(): View {     $products = Product::with([         'categories',         'media' => new LoadThumbnail(),         'variant.media' => new LoadThumbnail(),     ])->tap(new Available())->get();      return $this->view->make('products.index', compact('products')); }<\/code><\/pre>\n<p>\u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 <code>toArray<\/code> \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>LoadThumbnail<\/code>. \u042d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0412\u0430\u043c \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0436\u0430\u0434\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0437\u0430 \u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>with((new LoadThumbnail)->toArray())<\/code>. \u042d\u0442\u0430 \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438, \u0447\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u043e\u0432\u043d\u043e \u0447\u0438\u0442\u0435\u0440\u0441\u0442\u0432\u043e.  \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0439\u0442\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437 \u0411\u0414 \u043f\u043e <code>Pipeline<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u043e\u0441\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u041b\u0435\u043d\u044c &#8212; \u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u0438\u0435!<\/p>\n<h2>Invokable \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u044b<\/h2>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0451\u043c\u0430\u0445, \u043a\u0430\u043a \u0444\u0430\u043d\u0442\u043e\u043c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0415\u0441\u043b\u0438 \u0412\u044b \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 \u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b, \u0442\u043e, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0435\u0433\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a \u044d\u0442\u043e\u043c\u0443. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0444\u0430\u043d\u0442\u043e\u043c\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0442 \u043d\u0430\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e (\u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e) \u043a\u0430\u0441\u0442\u0430, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a <code>$address->lines<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u0442 <code>CastsOutboundAttributes<\/code>, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u043e\u043b\u0441\u0442\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u043a\u0441\u0442\u0430\u0442\u0438, <code>Attribute::get<\/code> \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442):<\/p>\n<pre><code class=\"php\">final class File extends Model {     protected function stream(): Attribute     {         return Attribute::get(new StreamableUrl($this));     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0441\u0451 \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0442.\u043a. \u044d\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>StreamableUrl<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442, \u043a\u0430\u043a \u0412\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 URL-\u0430\u0434\u0440\u0435\u0441\u043e\u0432. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/laravel.com\/docs\/eloquent-mutators#defining-an-accessor\" rel=\"noopener noreferrer nofollow\">\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439<\/a>, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b \u043a \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0442\u043e\u043b\u0441\u0442\u0443\u044e. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0437\u044f\u0442 \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0447\u0435\u0442\u044b\u0440\u043d\u0430\u0434\u0446\u0430\u0442\u044c (!) \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u044b\u0448\u0435:<\/p>\n<pre><code class=\"php\">final readonly class StreamableUrl {     private const S3_PROTOCOL = 's3:\/\/';      public function __construct(private File $file) {}      public function __invoke(): string     {         $basePath = UuidPathGenerator::getInstance()             ->getPath($this->file);          if ($this->file->supports('s3')) {             return self::S3_PROTOCOL                  . $this->file->bucket                  . DIRECTORY_SEPARATOR                  . $basePath                  . $this->file->basename;         }          return Storage::disk($this->file->disk)             ->url($basePath . rawurlencode($this->file->basename));     } }<\/code><\/pre>\n<p>\u0422\u043e\u0447\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u044b, \u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 URL. \u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u043f\u0440\u044f\u043c\u044b\u0445 <code>s3:\/\/<\/code> \u043f\u0443\u0442\u0435\u0439 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/aws.amazon.com\/s3\/\" rel=\"noopener noreferrer nofollow\">S3<\/a>.<\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 &#8212; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0431\u044d\u043a\u0430 \u0432 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u0435 \u0441\u0430\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0431\u044b \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0438\u043d\u0430\u0434\u0446\u0430\u0442\u0438. \u041d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043b\u0430 \u0431\u044b \u0442\u043e\u043b\u0441\u0442\u043e\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445.<\/p>\n<h2>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h2>\n<p>\u042d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0435\u0445 \u0440\u0435\u0434\u043a\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u043b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f <a href=\"https:\/\/muhammedsari.me\/nova.laravel.com\" rel=\"noopener noreferrer nofollow\">Laravel Nova<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0440\u0443\u0434\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u043d\u0435\u043b\u044f\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043c\u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441 \u0442\u0440\u0435\u0442\u044c\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438. \u041e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0435 \u043c\u043e\u0433\u043b\u043e \u0431\u044b\u0442\u044c \u0438 \u0440\u0435\u0447\u0438 \u0442\u0430\u043a \u043a\u0430\u043a, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0443\u0436\u0435 \u0440\u0435\u0448\u0451\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u0434\u043e\u043b\u0433\u043e. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/spatie\/laravel-medialibrary\" rel=\"noopener noreferrer nofollow\">laravel-medialibrary<\/a> (\u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0434\u0440\u0430\u0432\u043e\u043c\u044b\u0441\u043b\u044f\u0449\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0441\u043f\u0430\u0441\u0438\u0431\u043e Spatie!), \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u044f\u043b\u043e \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 Nova \u0443\u0434\u043e\u0431\u043d\u044b\u0439 UX-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0434 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c <code>Directory<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u044b, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443, \u0438 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c. \u0425\u043e\u0442\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c <code>Media<\/code> \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430 \u0441 \u0441\u0430\u043c\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0432 Nova \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 (\u0442\u0430\u043a\u0436\u0435 \u043e\u0442 Spatie). \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0418 \u043c\u0435\u043d\u044f \u043e\u0441\u0435\u043d\u0438\u043b\u043e: \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>media<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435:<\/p>\n<pre><code class=\"php\">final class File extends Model implements Sortable {     use SortableTrait;      public array $sortable = [         'order_column_name' => 'order_column';     ];      protected $table = 'media';      public function buildSortQuery(): Builder     {         return $this->newQuery()->where($this->only('model_id'));     } }<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0435\u0449\u0430\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435. \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u043e \u0432\u0441\u0435\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>media<\/code>, \u0447\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043f\u0440\u0435\u0434\u0432\u0438\u0434\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0442\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0431\u044b\u043b\u043e \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c <code>Media<\/code>, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u043c \u0434\u0432\u0443\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c:<\/p>\n<ul>\n<li>\n<p>\u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 <code>Directory<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>collection_name<\/code> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u043e\u0443\u043f \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0432 <code>ServiceProvider<\/code> \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b (\u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0435\u0434\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u043e\u0443\u043f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b):<\/p>\n<pre><code class=\"php\">final class FileScope implements Scope {     \/** @param File $model *\/     public function apply(Builder $builder, Model $model): void     {         $builder             ->where($model->qualifyColumn('model_type'), 'directory')             ->where($model->qualifyColumn('collection_name'), 'file');     } }<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u044d\u0442\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c, \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0438\u0441\u044c, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f <code>ModelNotFoundException<\/code>. \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0431\u0435\u0434\u044b \u0431\u044b\u043b\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u043d\u043e. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Nova \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u043a\u0443\u0447\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Media<\/code>. \u041d\u043e \u0442\u0443\u0442 \u043c\u0435\u043d\u044f \u0432\u043d\u043e\u0432\u044c \u043e\u0441\u0435\u043d\u0438\u043b\u043e: \u0440\u0430\u0437 \u044d\u0442\u043e \u043d\u0430\u0448\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u043e \u044f \u043c\u043e\u0433\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0443! \u042f \u0434\u0430\u0436\u0435 \u043c\u043e\u0433\u0443 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Directory<\/code>:<\/p>\n<pre><code class=\"php\">public function files(): HasMany {     return $this->hasMany(File::class, 'model_id')->ordered(); }<\/code><\/pre>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043b\u0438 \u0412\u044b \u0447\u0442\u043e-\u0442\u043e &#171;\u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0435&#187;? \u041d\u0435\u0442? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0442\u0438\u043f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0431\u044b \u0412\u044b \u0437\u043d\u0430\u043b\u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>MediaLibrary<\/code>, \u0442\u043e \u043f\u043e\u043d\u044f\u043b\u0438 \u0431\u044b, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <code>media<\/code> \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 <code>MorphMany<\/code>, \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u043e\u0443\u043f <code>FileScope<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0442\u043e\u0447\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e <code>model_type<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u0430 <code>HasMany<\/code> \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435, \u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412\u043e\u0442 \u0442\u0443\u0442-\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043a\u0440\u044b\u0448\u0443 \u0438 \u0441\u043d\u0435\u0441\u043b\u043e. \u0412\u044b\u0437\u043e\u0432 <code>$directory->files<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>File<\/code>, \u0430 \u043d\u0435 <code>Media<\/code>. \u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, <code>File<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0438 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0435\u0449\u0451. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0438 \u0438 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u044b\u043b \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u044b\u043c.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u043c\u043e\u0433 \u0431\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0443\u0447\u0443 <a href=\"https:\/\/muhammedsari.me\/unorthodox-eloquent#invokeable-accessors\" rel=\"noopener noreferrer nofollow\">(\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445) \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432<\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<pre><code class=\"php\">\/\/ other accessors ommitted, there's simply too many  protected function realpath(): Attribute {     return Attribute::get(new Realpath($this)); }  protected function stream(): Attribute {     return Attribute::get(new StreamableUrl($this)); }  protected function extension(): Attribute {     return Attribute::get(fn () => $this->type->extension()); }  protected function type(): Attribute {     return Attribute::get(fn () => FileType::from($this->mime)); }<\/code><\/pre>\n<h3>\u041f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438<\/h3>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043a\u043e\u0443\u043f\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043b\u043e\u0445\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043d\u043a\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0442\u0435\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u0430\u043a\u0435\u0442 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438\u043c &#171;\u0431\u0430\u0437\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c&#187;. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0430\u043a\u0435\u0442\u0430, \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ul>\n<h2>WithoutRelations \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439<\/h2>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c, &#8212; \u044d\u0442\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0438 \u043c\u0435\u0442\u043e\u0434 <code>WithoutRelations<\/code>. \u0417\u0430\u044f\u0434\u043b\u044b\u0435 \u0438 \u0437\u043e\u0440\u043a\u0438\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Laravel, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 <a href=\"https:\/\/github.com\/laravel\/jetstream\/blame\/4.x\/src\/Http\/Livewire\/UpdateProfileInformationForm.php#L46\" rel=\"noopener noreferrer nofollow\">Livewire \u0432 Laravel Jetstream<\/a>. \u041f\u0440\u0430\u0432\u0434\u0430, \u0437\u0434\u0435\u0441\u044c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0443\u0442\u0435\u0447\u043a\u0443 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0447\u0442\u043e, \u0445\u043e\u0442\u044f \u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u043e, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c.<\/p>\n<p>\u041a\u0430\u043a \u0412\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0435\u0441\u043b\u0438 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0436\u043e\u0431\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c Eloquent, \u0412\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u0439\u0442 <code>SerializesModels<\/code>. (\u0415\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0440\u0430\u0442\u043a\u043e <a href=\"https:\/\/laravel.com\/docs\/queues#class-structure\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f). \u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u0437\u043d\u0430\u044e\u0442: <code>SerializesModels<\/code> \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<pre><code class=\"json\">{     \"user\": {         \"class\": \"App\\\\Models\\\\User\",         \"id\": 10269,         \"relations\": ['company', 'orders', 'likes'],         \"connection\": \"mysql\",         \"collectionClass\": null     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>relations<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u0430. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u043f\u0440\u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u0436\u043e\u0431\u044b. \u0422\u0430\u043a\u0438\u0435 \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u044b \u043a\u0430\u043a <code>likes<\/code> \u0438 <code>orders<\/code> \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u044f\u043d\u0443\u0442\u044c \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u0442\u043d\u0438 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0442\u044b\u0441\u044f\u0447\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0434\u0436\u043e\u0431\u044b. \u0415\u0449\u0451 \u0445\u0443\u0436\u0435 \u0442\u043e, \u0447\u0442\u043e \u0434\u0436\u043e\u0431\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0432\u0437\u044f\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u043b\u0430\u0441\u044c \u043d\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u044d\u0442\u0438\u0445 \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u0430<\/h3>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>withoutRelations<\/code> \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 Eloquent \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Jobs<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">final class AccessIdentitySubscriber {     public function subscribe(Dispatcher $events): void     {         $events->listen(             Registered::class,              $this->whenRegistered(...),         );     }      private function whenRegistered(Registered $event): void     {         CreateProspect::dispatch($event->user->withoutRelations());     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u044d\u0432\u0435\u043d\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 CRM-\u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u041f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 <code>CreateProspect<\/code> \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>withoutRelations<\/code> \u0441 \u0446\u0435\u043b\u044c\u044e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u044b\u043b \u043e\u0447\u0438\u0449\u0435\u043d:<\/p>\n<pre><code class=\"json\">{     \"user\": {         \"class\": \"App\\\\Models\\\\User\",         \"id\": 10269,         \"relations\": [],         \"connection\": \"mysql\",         \"collectionClass\": null     } }<\/code><\/pre>\n<p>\u0428\u0438\u043a\u0430\u0440\u043d\u043e!.<\/p>\n<h3>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430<\/h3>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 Laravel \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 <a href=\"https:\/\/github.com\/laravel\/framework\/pull\/47989\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043d\u043e\u0432\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 #[WithoutRelations]<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u0438\u0442 \u0432\u0441\u0435 \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0436\u043e\u0431\u044b:<\/p>\n<pre><code class=\"php\">#[WithoutRelations] final class CreateProspect implements ShouldQueue {     use Dispatchable;     use InteractsWithQueue;     use SerializesModels;      public function __construct(private User $user) {}      public function handle(Gateway $crm): void     {         \/\/ omitted for brevity     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0436\u043e\u0431. \u041d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a \u0443 \u0412\u0430\u0441, \u0430 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b \u044f \u0441\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u0435: &#171;\u0427\u0451\u0440\u0442 \u0432\u043e\u0437\u044c\u043c\u0438, \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u044b \u0432 \u043f\u043e\u043a\u043e\u0435&#187;. \u0422\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u043d\u043e\u0441\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u0447\u0435\u043c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0435\u0449\u0451 (\u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443). \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 <a href=\"https:\/\/laravel.com\/docs\/eloquent-relationships#relationship-methods-vs-dynamic-properties\" rel=\"noopener noreferrer nofollow\">\u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/a> \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u043b\u043e\u0445\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/laravel.com\/docs\/eloquent-relationships#preventing-lazy-loading\" rel=\"noopener noreferrer nofollow\">Model::preventLazyLoading<\/a>. \u0418\u0437\u0432\u0438\u043d\u0438, <a href=\"https:\/\/twitter.com\/taylorotwell\/status\/1395087054254526474\" rel=\"noopener noreferrer nofollow\">\u0442\u0451\u0437\u043a\u0430<\/a>.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u0438 \u043f\u0430\u043b\u044c\u0446\u044b \u043e\u043d\u0435\u043c\u0435\u043b\u0438, \u043d\u043e, \u044f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043e\u043d\u043e \u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u043b\u043e. \u041b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0412\u0430\u0441 \u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0438\u0437 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0410\u0434\u0430 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0439\u0442\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0441\u0430\u043c\u043e\u0435 \u0445\u0443\u0434\u0448\u0435\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, &#8212; \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0412\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u0435\u0441\u044c. \u0418, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u043e <a href=\"https:\/\/shawnmc.cool\/2023-02-13_active-record-how-we-got-persistence-perfectly-wrong\" rel=\"noopener noreferrer nofollow\">\u043d\u044e\u0430\u043d\u0441\u0430\u0445 Active Record<\/a>. \u0421\u0430\u043c\u043e\u0435 \u0445\u0443\u0434\u0448\u0435\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, &#8212; \u044d\u0442\u043e, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0412\u0430\u0448\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/762690\/\"> https:\/\/habr.com\/ru\/articles\/762690\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0412\u044b \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/762598\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c<\/a>, \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c!<\/p>\n<h2>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/h2>\n<p>\u042d\u0442\u043e \u043a\u0440\u0430\u0442\u043a\u0430\u044f, \u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u0430\u044f (\u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435) \u0433\u043b\u0430\u0432\u0430. \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0412\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0437\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0436\u0430\u0434\u043d\u044b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0435 \u0443\u0447\u0430\u0441\u0442\u043a\u0438 \u043a\u043e\u0434\u0430. \u0425\u043e\u0442\u044f \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438\u0437-\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0430\u043d\u0442\u0430\u0441\u043c\u0430\u0433\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u00a0<a href=\"https:\/\/github.com\/spatie\/laravel-medialibrary\" rel=\"noopener noreferrer nofollow\">laravel-medialibrary\u00a0<\/a>\u043e\u0442 Spatie.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435, \u0447\u0442\u043e \u0443 \u0412\u0430\u0441 \u0435\u0441\u0442\u044c 10 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041a\u0430\u0436\u0434\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 <code>MediaCollections<\/code> \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0432\u044c\u044e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u041f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0442.\u0434. \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0449\u0438\u043c (\u0434\u0430 \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435). \u041f\u0430\u043a\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043e\u0434\u043d\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043c\u0435\u0434\u0438\u0430-\u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u043e\u043c, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u043c \u0432\u0441\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0434\u0438\u0430-\u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043c\u0430\u0433\u0438\u044e <code>Collection<\/code> \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u043b\u044f \u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0416\u0430\u0434\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432\u0441\u0435\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u0433\u0434\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043a\u0443\u0447\u0435\u0439 <code>MediaCollections<\/code>. \u0412\u0435\u0434\u044c, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430 \u043d\u0435\u0439 &#8212; \u044d\u0442\u043e \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u0435\u0432\u044c\u044e. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre><code class=\"php\">public function index(): View {     $products = Product::with([         'categories',         'media' => static function (MorphMany $query) {             $query->where('collection_name', 'thumbnail')         },         'variant.media' => static function (MorphMany $query) {             $query->where('collection_name', 'thumbnail')         },     ])->tap(new Available())->get();      return $this->view->make('products.index', compact('products')); }<\/code><\/pre>\n<p>\u0425\u043e\u0442\u044f \u044d\u0442\u043e \u0438 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437. \u0424\u0443! \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u043e \u0431\u0435\u0437\u0443\u043c\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 &#171;\u0436\u0430\u0434\u043d\u043e&#187; \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c. \u041f\u043e\u043d\u044f\u043b\u0438? \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>LoadThumbnail<\/code>:<\/p>\n<pre><code class=\"php\">final readonly class LoadThumbnail implements Arrayable {     public function __invoke(MorphMany $query): void     {         $query->where('collection_name', 'thumbnail');     }      public function toArray(): array     {         return ['media' => $this];     } }<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0435\u0433\u043e:<\/p>\n<pre><code class=\"php\">public function index(): View {     $products = Product::with([         'categories',         'media' => new LoadThumbnail(),         'variant.media' => new LoadThumbnail(),     ])->tap(new Available())->get();      return $this->view->make('products.index', compact('products')); }<\/code><\/pre>\n<p>\u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 <code>toArray<\/code> \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>LoadThumbnail<\/code>. \u042d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0412\u0430\u043c \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0436\u0430\u0434\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0437\u0430 \u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>with((new LoadThumbnail)->toArray())<\/code>. \u042d\u0442\u0430 \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438, \u0447\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u043e\u0432\u043d\u043e \u0447\u0438\u0442\u0435\u0440\u0441\u0442\u0432\u043e.  \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0439\u0442\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437 \u0411\u0414 \u043f\u043e <code>Pipeline<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u043e\u0441\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u041b\u0435\u043d\u044c &#8212; \u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u0438\u0435!<\/p>\n<h2>Invokable \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u044b<\/h2>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0451\u043c\u0430\u0445, \u043a\u0430\u043a \u0444\u0430\u043d\u0442\u043e\u043c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0415\u0441\u043b\u0438 \u0412\u044b \u0435\u0449\u0451 \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 \u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b, \u0442\u043e, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0435\u0433\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a \u044d\u0442\u043e\u043c\u0443. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0444\u0430\u043d\u0442\u043e\u043c\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043e\u0442 \u043d\u0430\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e (\u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e) \u043a\u0430\u0441\u0442\u0430, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a <code>$address->lines<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u0442 <code>CastsOutboundAttributes<\/code>, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u043e\u043b\u0441\u0442\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u043a\u0441\u0442\u0430\u0442\u0438, <code>Attribute::get<\/code> \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442):<\/p>\n<pre><code class=\"php\">final class File extends Model {     protected function stream(): Attribute     {         return Attribute::get(new StreamableUrl($this));     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0441\u0451 \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0442.\u043a. \u044d\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>StreamableUrl<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442, \u043a\u0430\u043a \u0412\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 URL-\u0430\u0434\u0440\u0435\u0441\u043e\u0432. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/laravel.com\/docs\/eloquent-mutators#defining-an-accessor\" rel=\"noopener noreferrer nofollow\">\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439<\/a>, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b \u043a \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0442\u043e\u043b\u0441\u0442\u0443\u044e. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0437\u044f\u0442 \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0447\u0435\u0442\u044b\u0440\u043d\u0430\u0434\u0446\u0430\u0442\u044c (!) \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u044b\u0448\u0435:<\/p>\n<pre><code class=\"php\">final readonly class StreamableUrl {     private const S3_PROTOCOL = 's3:\/\/';      public function __construct(private File $file) {}      public function __invoke(): string     {         $basePath = UuidPathGenerator::getInstance()             ->getPath($this->file);          if ($this->file->supports('s3')) {             return self::S3_PROTOCOL                  . $this->file->bucket                  . DIRECTORY_SEPARATOR                  . $basePath                  . $this->file->basename;         }          return Storage::disk($this->file->disk)             ->url($basePath . rawurlencode($this->file->basename));     } }<\/code><\/pre>\n<p>\u0422\u043e\u0447\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u044b, \u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 URL. \u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u043f\u0440\u044f\u043c\u044b\u0445 <code>s3:\/\/<\/code> \u043f\u0443\u0442\u0435\u0439 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/aws.amazon.com\/s3\/\" rel=\"noopener noreferrer nofollow\">S3<\/a>.<\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 &#8212; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0431\u044d\u043a\u0430 \u0432 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u0435 \u0441\u0430\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0431\u044b \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0438\u043d\u0430\u0434\u0446\u0430\u0442\u0438. \u041d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043b\u0430 \u0431\u044b \u0442\u043e\u043b\u0441\u0442\u043e\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445.<\/p>\n<h2>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h2>\n<p>\u042d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0435\u0445 \u0440\u0435\u0434\u043a\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u043b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f <a href=\"https:\/\/muhammedsari.me\/nova.laravel.com\" rel=\"noopener noreferrer nofollow\">Laravel Nova<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0440\u0443\u0434\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u043d\u0435\u043b\u044f\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043c\u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441 \u0442\u0440\u0435\u0442\u044c\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438. \u041e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0435 \u043c\u043e\u0433\u043b\u043e \u0431\u044b\u0442\u044c \u0438 \u0440\u0435\u0447\u0438 \u0442\u0430\u043a \u043a\u0430\u043a, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0443\u0436\u0435 \u0440\u0435\u0448\u0451\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u0434\u043e\u043b\u0433\u043e. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/spatie\/laravel-medialibrary\" rel=\"noopener noreferrer nofollow\">laravel-medialibrary<\/a> (\u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0434\u0440\u0430\u0432\u043e\u043c\u044b\u0441\u043b\u044f\u0449\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0441\u043f\u0430\u0441\u0438\u0431\u043e Spatie!), \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u044f\u043b\u043e \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 Nova \u0443\u0434\u043e\u0431\u043d\u044b\u0439 UX-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0434 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c <code>Directory<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u044b, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443, \u0438 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c. \u0425\u043e\u0442\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c <code>Media<\/code> \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430 \u0441 \u0441\u0430\u043c\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0432 Nova \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 (\u0442\u0430\u043a\u0436\u0435 \u043e\u0442 Spatie). \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0418 \u043c\u0435\u043d\u044f \u043e\u0441\u0435\u043d\u0438\u043b\u043e: \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>media<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435:<\/p>\n<pre><code class=\"php\">final class File extends Model implements Sortable {     use SortableTrait;      public array $sortable = [         'order_column_name' => 'order_column';     ];      protected $table = 'media';      public function buildSortQuery(): Builder     {         return $this->newQuery()->where($this->only('model_id'));     } }<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0435\u0449\u0430\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435. \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u043e \u0432\u0441\u0435\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>media<\/code>, \u0447\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043f\u0440\u0435\u0434\u0432\u0438\u0434\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0442\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0431\u044b\u043b\u043e \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c <code>Media<\/code>, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u043c \u0434\u0432\u0443\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c:<\/p>\n<ul>\n<li>\n<p>\u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 <code>Directory<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>collection_name<\/code> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u043e\u0443\u043f \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0432 <code>ServiceProvider<\/code> \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b (\u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0435\u0434\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u043e\u0443\u043f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b):<\/p>\n<pre><code class=\"php\">final class FileScope implements Scope {     \/** @param File $model *\/     public function apply(Builder $builder, Model $model): void     {         $builder             ->where($model->qualifyColumn('model_type'), 'directory')             ->where($model->qualifyColumn('collection_name'), 'file');     } }<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u044d\u0442\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c, \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0438\u0441\u044c, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f <code>ModelNotFoundException<\/code>. \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0431\u0435\u0434\u044b \u0431\u044b\u043b\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u043d\u043e. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Nova \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u043a\u0443\u0447\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Media<\/code>. \u041d\u043e \u0442\u0443\u0442 \u043c\u0435\u043d\u044f \u0432\u043d\u043e\u0432\u044c \u043e\u0441\u0435\u043d\u0438\u043b\u043e: \u0440\u0430\u0437 \u044d\u0442\u043e \u043d\u0430\u0448\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u043e \u044f \u043c\u043e\u0433\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0443! \u042f \u0434\u0430\u0436\u0435 \u043c\u043e\u0433\u0443 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Directory<\/code>:<\/p>\n<pre><code class=\"php\">public function files(): HasMany {     return $this->hasMany(File::class, 'model_id')->ordered(); }<\/code><\/pre>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043b\u0438 \u0412\u044b \u0447\u0442\u043e-\u0442\u043e &#171;\u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0435&#187;? \u041d\u0435\u0442? \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0442\u0438\u043f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0431\u044b \u0412\u044b \u0437\u043d\u0430\u043b\u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>MediaLibrary<\/code>, \u0442\u043e \u043f\u043e\u043d\u044f\u043b\u0438 \u0431\u044b, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <code>media<\/code> \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 <code>MorphMany<\/code>, \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u043e\u0443\u043f <code>FileScope<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0442\u043e\u0447\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e <code>model_type<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0440\u0435\u043b\u0435\u0439\u0448\u0435\u043d\u0430 <code>HasMany<\/code> \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435, \u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412\u043e\u0442 \u0442\u0443\u0442-\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043a\u0440\u044b\u0448\u0443 \u0438 \u0441\u043d\u0435\u0441\u043b\u043e. \u0412\u044b\u0437\u043e\u0432 <code>$directory->files<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>File<\/code>, \u0430 \u043d\u0435 <code>Media<\/code>. \u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, <code>File<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043b\u0430\u0434\u0430\u043b \u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0438 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0435\u0449\u0451. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0438 \u0438 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u044b\u043b \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u044b\u043c.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u043c\u043e\u0433 \u0431\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0443\u0447\u0443 <a href=\"https:\/\/muhammedsari.me\/unorthodox-eloquent#invokeable-accessors\" rel=\"noopener noreferrer nofollow\">(\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445) \u0430\u043a\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432<\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<pre><code class=\"php\">\/\/<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-355560","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355560"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355560\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}