{"id":389552,"date":"2024-06-29T08:40:31","date_gmt":"2024-06-29T08:40:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=389552"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=389552","title":{"rendered":"<span>\u041b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Laravel nova \u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u043c\u043e\u0437\u0433 \u043e\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0439 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430<\/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<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>Laravel &#8212; \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a PHP. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u0423 \u043c\u0435\u043d\u044f \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f laravel \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f laravel nova. \u0418 \u0432\u0441\u0451 \u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0439 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u043e\u0432.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a8d\/db5\/329\/a8ddb532950e6e77cdb25b436b3970d5.png\" alt=\"laravel nova icon\" title=\"laravel nova icon\" width=\"492\" height=\"512\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8d\/db5\/329\/a8ddb532950e6e77cdb25b436b3970d5.png\"\/><figcaption>laravel nova icon<\/figcaption><\/figure>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0417\u0430\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u044d\u0442\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c: <\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u044f\u0437\u044b\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 &#8212; \u0421\u0415\u0421\u0421\u0418\u0418 Laravel nova.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432<\/h2>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0432 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 laravel nova \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432. \u0422\u0430\u043a \u043c\u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0441\u0443\u0440\u0441 nova.<\/p>\n<pre><code class=\"php\"> public function up()     {         Schema::create('languages', function (Blueprint $table) {             $table->id();             $table->string('key_lang', 255);             $table->string('title', 255);             $table->timestamps();         });     } \/\/\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u044f\u0437\u044b\u043a\u043e\u0432<\/code><\/pre>\n<pre><code class=\"php\">public function fields(Request $request)     {         return [             ID::make(__('ID'), 'id')->sortable(),              Text::make(__(\"LanguageKey\"), 'key_lang')                 ->rules('required')                 ->sortable(),              Text::make(__(\"Title\"), 'title')                 ->rules('required')                 ->sortable()         ];     } \/\/\u0440\u0435\u0441\u0443\u0440\u0441 nova \u044f\u0437\u044b\u043a\u043e\u0432<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/181\/e35\/e53\/181e35e53b164976122ec484a7622cdc.png\" width=\"1615\" height=\"565\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/181\/e35\/e53\/181e35e53b164976122ec484a7622cdc.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0438<\/h2>\n<p>\u0422\u0430\u043a \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043b\u044f nova \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 resources\/lang\/vendor\/nova \u0432 json \u0444\u0430\u0439\u043b\u0430\u0445 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447 \u044f\u0437\u044b\u043a\u0430. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c observer \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b json laravel \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432 \u0411\u0414, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b json \u043f\u043e\u043b\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u044f\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"php\"> public function up()     {         Schema::create('admin_panels', function (Blueprint $table) {             $table->id();             $table->foreignId('key_lang_id')->unique()->constrained('languages');             $table->json('content');             $table->timestamps();         });     }     \/\/\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0441\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043d\u0435 \u043a\u043b\u044e\u0447\u0438 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 \u0432 \u043f\u043e\u043b\u0435 <code>armincms\/json (https:\/\/github.com\/armincms\/json).<\/code><\/p>\n<pre><code class=\"php\">protected static $adminField = [      'LoggingProfileChanges', 'ChangedByWhom', 'ListOfChanges' ...... \/\/ \u0412\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438  ];  public function fields(Request $request)     {         foreach (self::$adminField as $field) {             $res[] = Text::make(__($field), $field)                 ->rules('required')                 ->hideFromIndex();         }         $result = [             ID::make(__('ID'), 'id')->sortable(),              BelongsTo::make(__(\"LanguageKey\"), 'key_lang', Language::class)                 ->searchable(true)                 ->creationRules('unique:admin_panels,key_lang_id')                 ->updateRules('unique:admin_panels,key_lang_id,{{resourceId}}')                 ->sortable(),              Json::make(\"content\", $res)         ];         return $result;     }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 json \u0444\u0430\u0439\u043b\u044b nova \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f observer. \u041d\u0430\u043f\u0438\u0441\u0430\u0432 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 json \u0444\u0430\u0439\u043b\u0430 \u044f \u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0443\u0441\u043f\u0435\u0445\u0430.<\/p>\n<pre><code>public function created(AdminPanel $adminPanel)     {         $data = $adminPanel->getAttributes();         $lang = Language::find($data['key_lang_id']);         $path = resource_path('\/lang\/vendor\/nova\/'.$lang->key_lang.'.json');         if (file_exists($path)) {             $file = file_get_contents($path);             $original = json_decode($file, True);             $original = array_replace_recursive($original, json_decode($data['content'], True));             $handle = fopen($path, 'w+');             fputs($handle, json_encode($original));             fclose($handle);         } else {             $handle = fopen($path, 'w+');             fputs($handle, $data['content']);             fclose($handle);         }     }          public function updated(AdminPanel $adminPanel)     {         $idLang = $adminPanel->getOriginal('key_lang_id');         $data = $adminPanel->getChanges();         if (isset($data['key_lang_id'])) {             $lang = Language::find($data['key_lang_id']);         } else {             $lang = Language::find($idLang);         }         $path = resource_path('\/lang\/vendor\/nova\/'.$lang->key_lang.'.json');         $file = file_get_contents($path);         $original = json_decode($file, True);         $original = array_replace_recursive($original, json_decode($data['content'], True));         $handle = fopen($path, 'w+');         fputs($handle, json_encode($original));         fclose($handle);     }<\/code><\/pre>\n<h2>\u0421\u0435\u0441\u0441\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u044f\u0437\u044b\u043a\u043e\u0432<\/h2>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u043e \u043d\u0430\u0447\u0430\u043b\u0443 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043b\u0451\u0433\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0442\u0430\u043a, \u043a\u0430\u043a \u044f \u0434\u0443\u043c\u0430\u043b \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435\u043b\u044c \u0441 laravel nova packages, \u043d\u043e \u044f \u043e\u0448\u0438\u0431\u0430\u043b\u0441\u044f. \u0412 \u0431\u043e\u043b\u044c\u0448\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043b\u0438\u0431\u043e \u043e\u043d\u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 laravel nova(<code>v3.23.2 )<\/code>, \u043b\u0438\u0431\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u044f\u0437\u044b\u043a\u0438 \u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u044f\u0437\u044b\u043a \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u044d\u0448, \u0447\u0442\u043e \u043c\u043d\u0435 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u0438\u043e\u0433\u0435 \u043f\u0440\u0438\u0448\u0451\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c. \u0421\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u0438 \u0437\u0430\u043b\u0438\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0439 \u0432 laravel nova. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u0443\u0436\u0435 \u0434\u0443\u043c\u0430\u043b \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0430\u043b. \u0414\u043e \u0434\u0435\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043a\u0430\u0437\u043a\u0447\u0438\u043a\u043e\u043c \u0431\u044b\u043b\u043e 3 \u0434\u043d\u044f. \u041f\u044b\u0442\u0430\u044f\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0434\u043d\u044f, \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u0442\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0414\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0442\u0430\u043a \u043e\u043f\u044b\u0442\u0430 \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0430 laravel \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u043b \u0433\u043e\u0434\u0430. <\/p>\n<p>\u041f\u043e\u0441\u0438\u0434\u0435\u0432 \u043d\u0430\u0434 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0434\u0432\u0430 \u0434\u043d\u044f \u043c\u043d\u0435 \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d resources\/views\/vendor\/nova\/partials\/user.blade.php<\/p>\n<p><strong>user.blade.php<\/strong><\/p>\n<pre><code class=\"php\">&lt;dropdown-trigger class=\"h-9 flex items-center\">     @isset($user->email)         &lt;img             src=\"https:\/\/secure.gravatar.com\/avatar\/{{ md5(\\Illuminate\\Support\\Str::lower($user->email)) }}?size=512\"             class=\"rounded-full w-8 h-8 mr-3\"         \/>     @endisset      &lt;span class=\"text-90\">         {{ $user->name ?? $user->email ?? __('Nova User') }}     &lt;\/span> &lt;\/dropdown-trigger>  &lt;dropdown-menu slot=\"menu\" width=\"200\" direction=\"rtl\">         &lt;ul class=\"list-reset\">         @foreach (App\\Http\\Controllers\\LanguageController::getLangs() as $lang => $language)             @if ($lang != Illuminate\\Support\\Facades\\App::getLocale())                 &lt;li>                 &lt;a class=\"block no-underline text-90 hover:bg-30 p-3\" href=\"{{ route('lang.switch', $lang) }}\"> {{$language}}&lt;\/a>                 &lt;\/li>             @endif         @endforeach         &lt;\/ul>     &lt;ul class=\"list-reset\">         &lt;li>             &lt;a href=\"{{ route('nova.logout') }}\" class=\"block no-underline text-90 hover:bg-30 p-3\">                 {{ __('Logout') }}             &lt;\/a>         &lt;\/li>     &lt;\/ul> &lt;\/dropdown-menu> <\/code><\/pre>\n<p><strong>LanguageController.php<\/strong><\/p>\n<pre><code class=\"php\"> public function switchLang($lang)     {         if (array_key_exists($lang, self::getLangs())) {             Session::put('applocale', $lang);         }         return Redirect::back();     }      public static function getLangs()     {         $result = [];         $allLang = Language::all();          foreach ($allLang as $lang) {             $result[$lang->key_lang] = $lang->title;         }          return $result;     }<\/code><\/pre>\n<p><strong>LanguageMiddleware.php<\/strong><\/p>\n<pre><code class=\"php\"> public function handle($request, Closure $next)     {         if (Session()->has('applocale') AND array_key_exists(Session()->get('applocale'), LanguageController::getLangs())) {             App::setLocale(Session()->get('applocale'));         }         else {              App::setLocale(config('app.fallback_locale'));         }         return $next($request);     }<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0432 Kernel:<\/p>\n<pre><code class=\"php\"> protected $middlewareGroups = [         'web' => [            ...             \\App\\Http\\Middleware\\Language::class,         ], ...     ];<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430.<\/p>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043c\u0435\u043d\u044f \u0432\u044b\u0448\u0435\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0441 \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438. <\/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\/577088\/\"> https:\/\/habr.com\/ru\/articles\/577088\/<\/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<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>Laravel &#8212; \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a PHP. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u0423 \u043c\u0435\u043d\u044f \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f laravel \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f laravel nova. \u0418 \u0432\u0441\u0451 \u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0439 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u043e\u0432.<\/p>\n<figure class=\"\"><figcaption>laravel nova icon<\/figcaption><\/figure>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0417\u0430\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u044d\u0442\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c: <\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u044f\u0437\u044b\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 &#8212; \u0421\u0415\u0421\u0421\u0418\u0418 Laravel nova.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432<\/h2>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0432 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 laravel nova \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432. \u0422\u0430\u043a \u043c\u043d\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0441\u0443\u0440\u0441 nova.<\/p>\n<pre><code class=\"php\"> public function up()     {         Schema::create('languages', function (Blueprint $table) {             $table->id();             $table->string('key_lang', 255);             $table->string('title', 255);             $table->timestamps();         });     } \/\/\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u044f\u0437\u044b\u043a\u043e\u0432<\/code><\/pre>\n<pre><code class=\"php\">public function fields(Request $request)     {         return [             ID::make(__('ID'), 'id')->sortable(),              Text::make(__(\"LanguageKey\"), 'key_lang')                 ->rules('required')                 ->sortable(),              Text::make(__(\"Title\"), 'title')                 ->rules('required')                 ->sortable()         ];     } \/\/\u0440\u0435\u0441\u0443\u0440\u0441 nova \u044f\u0437\u044b\u043a\u043e\u0432<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0438<\/h2>\n<p>\u0422\u0430\u043a \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043b\u044f nova \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 resources\/lang\/vendor\/nova \u0432 json \u0444\u0430\u0439\u043b\u0430\u0445 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447 \u044f\u0437\u044b\u043a\u0430. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c observer \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b json laravel \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432 \u0411\u0414, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b json \u043f\u043e\u043b\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u044f\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"php\"> public function up()     {         Schema::create('admin_panels', function (Blueprint $table) {             $table->id();             $table->foreignId('key_lang_id')->unique()->constrained('languages');             $table->json('content');             $table->timestamps();         });     }     \/\/\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0441\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043d\u0435 \u043a\u043b\u044e\u0447\u0438 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 \u0432 \u043f\u043e\u043b\u0435 <code>armincms\/json (https:\/\/github.com\/armincms\/json).<\/code><\/p>\n<pre><code class=\"php\">protected static $adminField = [      'LoggingProfileChanges', 'ChangedByWhom', 'ListOfChanges' ...... \/\/ \u0412\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438  ];  public function fields(Request $request)     {         foreach (self::$adminField as $field) {             $res[] = Text::make(__($field), $field)                 ->rules('required')                 ->hideFromIndex();         }         $result = [             ID::make(__('ID'), 'id')->sortable(),              BelongsTo::make(__(\"LanguageKey\"), 'key_lang', Language::class)                 ->searchable(true)                 ->creationRules('unique:admin_panels,key_lang_id')                 ->updateRules('unique:admin_panels,key_lang_id,{{resourceId}}')                 ->sortable(),              Json::make(\"content\", $res)         ];         return $result;     }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 json \u0444\u0430\u0439\u043b\u044b nova \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f observer. \u041d\u0430\u043f\u0438\u0441\u0430\u0432 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 json \u0444\u0430\u0439\u043b\u0430 \u044f \u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0443\u0441\u043f\u0435\u0445\u0430.<\/p>\n<pre><code>public function created(AdminPanel $adminPanel)     {         $data = $adminPanel->getAttributes();         $lang = Language::find($data['key_lang_id']);         $path = resource_path('\/lang\/vendor\/nova\/'.$lang->key_lang.'.json');         if (file_exists($path)) {             $file = file_get_contents($path);             $original = json_decode($file, True);             $original = array_replace_recursive($original, json_decode($data['content'], True));             $handle = fopen($path, 'w+');             fputs($handle, json_encode($original));             fclose($handle);         } else {             $handle = fopen($path, 'w+');             fputs($handle, $data['content']);             fclose($handle);         }     }          public function updated(AdminPanel $adminPanel)     {         $idLang = $adminPanel->getOriginal('key_lang_id');         $data = $adminPanel->getChanges();         if (isset($data['key_lang_id'])) {             $lang = Language::find($data['key_lang_id']);         } else {             $lang = Language::find($idLang);         }         $path = resource_path('\/lang\/vendor\/nova\/'.$lang->key_lang.'.json');         $file = file_get_contents($path);         $original = json_decode($file, True);         $original = array_replace_recursive($original, json_decode($data['content'], True));         $handle = fopen($path, 'w+');         fputs($handle, json_encode($original));         fclose($handle);     }<\/code><\/pre>\n<h2>\u0421\u0435\u0441\u0441\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u044f\u0437\u044b\u043a\u043e\u0432<\/h2>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044f \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u043e \u043d\u0430\u0447\u0430\u043b\u0443 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043b\u0451\u0433\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0442\u0430\u043a, \u043a\u0430\u043a \u044f \u0434\u0443\u043c\u0430\u043b \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435\u043b\u044c \u0441 laravel nova packages, \u043d\u043e \u044f \u043e\u0448\u0438\u0431\u0430\u043b\u0441\u044f. \u0412 \u0431\u043e\u043b\u044c\u0448\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043b\u0438\u0431\u043e \u043e\u043d\u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 laravel nova(<code>v3.23.2 )<\/code>, \u043b\u0438\u0431\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u044f\u0437\u044b\u043a\u0438 \u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u044f\u0437\u044b\u043a \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u044d\u0448, \u0447\u0442\u043e \u043c\u043d\u0435 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u0438\u043e\u0433\u0435 \u043f\u0440\u0438\u0448\u0451\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c. \u0421\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u0438 \u0437\u0430\u043b\u0438\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0439 \u0432 laravel nova. \u0418 \u0442\u043e\u0433\u0434\u0430 \u044f \u0443\u0436\u0435 \u0434\u0443\u043c\u0430\u043b \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0430\u043b. \u0414\u043e \u0434\u0435\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043a\u0430\u0437\u043a\u0447\u0438\u043a\u043e\u043c \u0431\u044b\u043b\u043e 3 \u0434\u043d\u044f. \u041f\u044b\u0442\u0430\u044f\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0434\u043d\u044f, \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u0442\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0414\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0442\u0430\u043a \u043e\u043f\u044b\u0442\u0430 \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0430 laravel \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u043b \u0433\u043e\u0434\u0430. <\/p>\n<p>\u041f\u043e\u0441\u0438\u0434\u0435\u0432 \u043d\u0430\u0434 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0434\u0432\u0430 \u0434\u043d\u044f \u043c\u043d\u0435 \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d resources\/views\/vendor\/nova\/partials\/user.blade.php<\/p>\n<p><strong>user.blade.php<\/strong><\/p>\n<pre><code class=\"php\">&lt;dropdown-trigger class=\"h-9 flex items-center\">     @isset($user->email)         &lt;img             src=\"https:\/\/secure.gravatar.com\/avatar\/{{ md5(\\Illuminate\\Support\\Str::lower($user->email)) }}?size=512\"             class=\"rounded-full w-8 h-8 mr-3\"         \/>     @endisset      &lt;span class=\"text-90\">         {{ $user->name ?? $user->email ?? __('Nova User') }}     &lt;\/span> &lt;\/dropdown-trigger>  &lt;dropdown-menu slot=\"menu\" width=\"200\" direction=\"rtl\">         &lt;ul class=\"list-reset\">         @foreach (App\\Http\\Controllers\\LanguageController::getLangs() as $lang => $language)             @if ($lang != Illuminate\\Support\\Facades\\App::getLocale())                 &lt;li>                 &lt;a class=\"block no-underline text-90 hover:bg-30 p-3\" href=\"{{ route('lang.switch', $lang) }}\"> {{$language}}&lt;\/a>                 &lt;\/li>             @endif         @endforeach         &lt;\/ul>     &lt;ul class=\"list-reset\">         &lt;li>             &lt;a href=\"{{ route('nova.logout') }}\" class=\"block no-underline text-90 hover:bg-30 p-3\">                 {{ __('Logout') }}             &lt;\/a>         &lt;\/li>     &lt;\/ul> &lt;\/dropdown-menu> <\/code><\/pre>\n<p><strong>LanguageController.php<\/strong><\/p>\n<pre><code class=\"php\"> public function switchLang($lang)     {         if (array_key_exists($lang, self::getLangs())) {             Session::put('applocale', $lang);         }         return Redirect::back();     }      public static function getLangs()     {         $result = [];         $allLang = Language::all();          foreach ($allLang as $lang) {             $result[$lang->key_lang] = $lang->title;         }          return $result;     }<\/code><\/pre>\n<p><strong>LanguageMiddleware.php<\/strong><\/p>\n<pre><code class=\"php\"> public function handle($request, Closure $next)     {         if (Session()->has('applocale') AND array_key_exists(Session()->get('applocale'), LanguageController::getLangs())) {             App::setLocale(Session()->get('applocale'));         }         else {              App::setLocale(config('app.fallback_locale'));         }         return $next($request);     }<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0432 Kernel:<\/p>\n<pre><code class=\"php\"> protected $middlewareGroups = [         'web' => [            ...             \\App\\Http\\Middleware\\Language::class,         ], ...     ];<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430.<\/p>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043c\u0435\u043d\u044f \u0432\u044b\u0448\u0435\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u043e\u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0441 \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438. <\/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\/577088\/\"> https:\/\/habr.com\/ru\/articles\/577088\/<\/a><br \/><\/br><\/br><\/p>\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-389552","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/389552","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=389552"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/389552\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=389552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=389552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=389552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}