fjffk简单的咖啡店科开发2方法2 环滁皆山也。其西南诸峰,林壑尤美,望之蔚然而深秀者,琅琊也。山行六七里,渐闻水声潺潺,而泻出于两峰之间者,酿泉也 ??????????????????????????????? ??????????????/????????????????? ............/................... .........................../... ??????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dsdflaravel-json-mysql-locations-manager/LICENSE000064400000002065152665371660014736 0ustar00MIT License Copyright (c) 2023 Mahmud Elseyyidömer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. laravel-json-mysql-locations-manager/README.md000064400000004712152665371660015211 0ustar00# Laravel Json Localization Manager This is a package to manage json strings for Laravel 5.4 and higher Localization Translation Strings As Keys With MySQL. [Using Translation Strings As Keys][6ea2d96e] [6ea2d96e]: https://laravel.com/docs/5.4/localization#using-translation-strings-as-keys "Using Translation Strings As Keys" ## Composer require ``` bash $ composer require elseyyid/laravel-json-mysql-locations-manager ``` ## Add Provider into config/app.php ``` php Elseyyid\LaravelJsonLocationsManager\Providers\LaravelJsonLocationsManagerServiceProvider::class, ``` ### For Only local environment Add the following to the AppServiceProvider in the register function: #### app/Providers/AppServiceProvider.php ``` php if ($this->app->environment() == 'local' || $this->app->environment() == 'testing') { /* * Load third party local providers */ $this->app->register(\Elseyyid\LaravelJsonLocationsManager\Providers\LaravelJsonLocationsManagerServiceProvider::class); } ``` ## Package install Run in console this command ``` bash $ php artisan elseyyid:location:install ``` This command install database and will ask if you want to import the existing locations in the application. There are 2 questions, the first to import the strings in arrays and the second to import the existing strings into json files. This will pupulate the database with all strings. You don't need to run artisan migrate, this package uses an independent database (sqlite). ### Other Console Command You can publish all languages Json files in console running ``` bash $ php artisan elseyyid:location:publish ``` Of course you also can do that in browser views. ## Manage Locations Now you can access to /translations/home in your browser and manage all langs strings. - Search Language Strings - Add new Language - Add new Strings - Edit Strings - Publish / Update json Files ## Publish the views and config file ``` bash $ php artisan vendor:publish --provider='Elseyyid\LaravelJsonLocationsManager\Providers\LaravelJsonLocationsManagerServiceProvider' ``` ### In the config file you can call your custom layout, the content section and the scripts section (this is important for the edit views) and routes prefix and middlewares. ## Routes middlewares in config file you can add your middlewares, by default is only 'web' middleware ### Feel free to send improvements Created by [elseyyid][760a7857] [760a7857]: https://github.com/OmarElseyyid "https://github.com/OmarElseyyid" laravel-json-mysql-locations-manager/src/Controllers/HomeController.php000064400000011045152665371660022471 0ustar00files = $filesystem; } public function index() { if (Schema::hasTable('strings')) { $fields = \DB::getSchemaBuilder()->getColumnListing('strings'); } else { Artisan::call('elseyyid:location:install'); $fields = \DB::getSchemaBuilder()->getColumnListing('strings'); } $exceptions = ['en','code','created_at','updated_at']; $filtered = collect($fields)->filter(function ($value, $key) use($exceptions){ if (!in_array($value,$exceptions) ) { return $value; } }); return view('langs::home')->with('langs', $filtered); } public function lang($lang) { $list = Strings::select(['code','en',$lang])->get(); return view('langs::list')->with('lang', $lang)->with('list', $list); } public function update(Request $request,$code) { $column_name = $request->get('name'); $column_value = $request->get('value'); if($request->has('name') && $request->has('value')) { $test = Strings::select() ->where('code', '=', $code) ->update([$column_name => $column_value]); return response()->json([ 'code'=>200], 200); } return response()->json([ 'error'=> 400, 'message'=> 'Not enought params' ], 400); } public function generateJson($lang) { $list = Strings::pluck($lang,'en'); $json = json_encode_prettify($list); $this->files->put(base_path('lang/'.$lang.'.json'),$json); return redirect()->back()->with(config('elseyyid-location.message_success_variable'), 'Publicado'); } public function newLang(NewLangFormRequest $request) { $fields = \DB::getSchemaBuilder()->getColumnListing('strings'); if (! in_array( $request->newLang, $fields )) { Schema::table('strings', function (Blueprint $table) use($request){ $table->text($request->newLang)->nullable(); }); } return redirect()->route('elseyyid.translations.lang',$request->newLang)->with(config('elseyyid-location.message_success_variable'), 'Language '.$request->newLang. ' Created!'); } public function newString(NewStringFormRequest $request) { $string = Strings::where('en',$request->newString)->first(); if (!isset($string->code)) { Strings::create(['en' => $request->newString]); } return redirect()->back()->with(config('elseyyid-location.message_success_variable'), 'String '.$request->newString. ' Created!'); } public function search(SearchFormRequest $request) { $search_value = $request->search; $fields = collect(\DB::getSchemaBuilder()->getColumnListing('strings')); $columns = $fields->flip()->except(['code','created_at','updated_at'])->keys(); $query = Strings::select('*'); $query->where('en', 'LIKE', '%' . $search_value . '%'); foreach($columns as $column) { $query->orWhere($column, 'LIKE', '%' . $search_value . '%'); } $result = $query->get(); return view('langs::search_result')->with('result', $result)->with('search_value', $search_value); } public function string($code) { $string = Strings::find($code); return view('langs::lang')->with('string', $string); } public function publishAll() { $fields = collect(\DB::getSchemaBuilder()->getColumnListing('strings')); $columns = $fields->flip()->except(['code','en','created_at','updated_at'])->keys(); foreach ($columns as $lang) { $list = Strings::pluck($lang,'en'); $json = json_encode_prettify($list); $this->files->put(base_path('lang/'.$lang.'.json'),$json); } return redirect()->back()->with(config('elseyyid-location.message_success_variable'), __('All Json Files Published!')); } } laravel-json-mysql-locations-manager/src/Services/Helper.php000064400000000440152665371660020226 0ustar00 'required', ]; } } laravel-json-mysql-locations-manager/src/Requests/NewLangFormRequest.php000064400000001036152665371660022571 0ustar00 'required', ]; } } laravel-json-mysql-locations-manager/src/Requests/SearchFormRequest.php000064400000001034152665371660022441 0ustar00 'required', ]; } } laravel-json-mysql-locations-manager/src/Models/Strings.php000064400000000420152665371660020076 0ustar00{{__('Languages installed')}} @foreach ($langs as $lang)
{{__('Lang')}} {{ucfirst($lang)}}
@endforeach @endsection laravel-json-mysql-locations-manager/src/views/list.blade.php000064400000005166152665371660020414 0ustar00@extends(config('elseyyid-location.layout')) @section(config('elseyyid-location.content_section')) @include('langs::includes.tools')

Language {{ucfirst($lang)}}

Generate Json File
@foreach($list as $key => $value) @foreach ($value->toArray() as $key => $element) @if ($key !== 'code') @endif @endforeach @endforeach
{{$element}}Show
@endsection @section(config('elseyyid-location.scripts_section')) @endsection laravel-json-mysql-locations-manager/src/views/lang.blade.php000064400000003404152665371660020353 0ustar00@extends(config('elseyyid-location.layout')) @section(config('elseyyid-location.content_section')) @include('langs::includes.tools')

String {{$string->en}} ({{$string->code}})

@foreach (collect($string)->except(['code','created_at','updated_at'])->toArray() as $key => $element) {{$key}}
{{$element}}

@endforeach @endsection @section(config('elseyyid-location.scripts_section')) @endsection laravel-json-mysql-locations-manager/src/views/search_result.blade.php000064400000001766152665371660022306 0ustar00@extends(config('elseyyid-location.layout')) @section(config('elseyyid-location.content_section')) @include('langs::includes.tools')

{{__('Search Result for')}} '{{$search_value }}'

@if (count($result) > 0)
@foreach ($result as $element)
{{$element->en}}

@endforeach
@else

No results for {{ $search_value }}

@endif @endsection laravel-json-mysql-locations-manager/src/views/includes/nav.blade.php000064400000001606152665371660022026 0ustar00 laravel-json-mysql-locations-manager/src/views/includes/messages.blade.php000064400000003425152665371660023052 0ustar00@if ($errors->any())
@foreach ($errors->all() as $error) {!! $error !!}
@endforeach
@elseif (session()->get('flash_success'))
@if(is_array(json_decode(session()->get('flash_success'), true))) {!! implode('', session()->get('flash_success')->all(':message
')) !!} @else {!! session()->get('flash_success') !!} @endif
@elseif (session()->get('flash_warning'))
@if(is_array(json_decode(session()->get('flash_warning'), true))) {!! implode('', session()->get('flash_warning')->all(':message
')) !!} @else {!! session()->get('flash_warning') !!} @endif
@elseif (session()->get('flash_info'))
@if(is_array(json_decode(session()->get('flash_info'), true))) {!! implode('', session()->get('flash_info')->all(':message
')) !!} @else {!! session()->get('flash_info') !!} @endif
@elseif (session()->get('flash_danger'))
@if(is_array(json_decode(session()->get('flash_danger'), true))) {!! implode('', session()->get('flash_danger')->all(':message
')) !!} @else {!! session()->get('flash_danger') !!} @endif
@elseif (session()->get('flash_message'))
@if(is_array(json_decode(session()->get('flash_message'), true))) {!! implode('', session()->get('flash_message')->all(':message
')) !!} @else {!! session()->get('flash_message') !!} @endif
@endiflaravel-json-mysql-locations-manager/src/views/includes/tools.blade.php000064400000004540152665371660022402 0ustar00
{{__('Publish All Json Files')}} {{__('All Locations')}}
laravel-json-mysql-locations-manager/src/views/layouts/app.blade.php000064400000003135152665371660021713 0ustar00 Locations Manager @include('langs::includes.nav')
@include('langs::includes.messages') @yield('content')
@yield('scripts') laravel-json-mysql-locations-manager/src/Providers/LaravelJsonLocationsManagerServiceProvider.php000064400000003400152665371660027623 0ustar00loadViewsFrom(__DIR__ . '/../views', 'langs'); /*Load routes*/ $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); $this->publishes([ __DIR__ . '/../config/elseyyid-location.php' => base_path('config/elseyyid-location.php'), ], 'elseyyid-location'); $this->publishes([ __DIR__ . '/../views' => base_path('/resources/views/vendor/langs')], 'views'); } /** * Register the service provider. * * @return void */ public function register() { //Load helpers Helper::loadModuleHelpers(__DIR__); $this->mergeConfigFrom(__DIR__.'/../config/database.php','lang-manager'); $this->mergeConfigFrom(__DIR__.'/../config/elseyyid-location.php', 'elseyyid-location'); $this->commands($this->commands); } /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ InstallCommand::class, PublishAllCommand::class, ]; } laravel-json-mysql-locations-manager/src/Commands/InstallCommand.php000064400000020061152665371660021673 0ustar00files = $filesystem; } /** * Execute the console command. * * @return mixed */ public function handle() { if (!Schema::hasTable('strings')) { $this->createSchema(); } else { $this->createSchema("fresh"); } $this->line(''); $this->info('Database Created!'); $this->importJsonStrings(); $this->info('Json strings imported!'); $this->line('Package installed!'); $this->info(''); } public function importArraysStrings() { $files = $this->files->directories(base_path('lang')); $all = []; $langs = []; $codes = []; foreach ($files as $key => $value) { $lang = Arr::last(explode('/',$value)); if ($lang !== 'vendor' ) { array_push($langs,$lang); $a = $this->files->allFiles($value); $array = []; foreach ($a as $k => $v) { $m = explode('.php',Arr::last(explode('/',$v)))[0]; array_push($array,Arr::dot([$m => include($v)])); } list($keys, $values) = Arr::divide(Arr::collapse($array)); array_push($codes,$keys); array_push($all,[$lang => Arr::collapse($array)]); } } $languages = Arr::collapse($all); $codigos = collect(Arr::collapse($codes))->unique(); $this->isInTable($langs); $collect = collect(); foreach ($codigos as $key => $codigo) { $fila = []; foreach ($languages as $key => $arr) { if (Arr::has($arr, $codigo)) { array_push($fila,[$key => Arr::get($arr, $codigo)]); } } $collect->push(Arr::collapse($fila)); } $this->fill($collect); } public function importJsonStrings() { $json_files = $this->files->files(base_path('lang')); $all = []; $langs = []; $codes = []; foreach ($json_files as $key => $json_file) { if (str_contains($json_file, '.json')) { $lang = Arr::first(explode('.json', basename($json_file))); array_push($langs,$lang); $array = json_decode($this->files->get($json_file)); $keys = collect($array)->keys(); array_push($codes,$keys); array_push($all,[$lang => $array ]); } } $languages = Arr::collapse($all); $codigos = collect(Arr::collapse($codes))->unique(); $this->isInTable($langs); $collect = collect(); foreach ($codigos as $key => $codigo) { $fila = []; array_push($fila,['en' => $codigo]); foreach ($languages as $key => $arr) { if( $key == 'en' ){ continue; } $arr = (array) $arr; if (Arr::has($arr, $codigo)) { array_push($fila, [$key => $arr[$codigo]]); } } $collect->push(Arr::collapse($fila)); } $this->fill($collect); } public function fill($collect) { foreach ($collect as $key => $value) { if (!Arr::has($value,'en')) { $array = collect($value); $array->prepend(Arr::first($value),'en'); $string = Strings::where('en',$array['en'])->first(); if (!isset($string->code)) { Strings::create($array->toArray()); } } else { $string = Strings::where('en',$value['en'])->first(); if (!isset($string->code)) { Strings::create($value); } } } } public function createSchema($mode = null) { if ($mode === 'fresh') { $this->backupTable(); Schema::dropIfExists('strings'); } Schema::create('strings', function (Blueprint $table) { $table->increments('code')->unsigned(); $table->text('en')->nullable()->collation('utf8_bin'); $table->text('ar')->nullable()->collation('utf8_bin'); $table->text('da')->nullable()->collation('utf8_bin'); $table->text('de')->nullable()->collation('utf8_bin'); $table->text('el')->nullable()->collation('utf8_bin'); $table->text('es')->nullable()->collation('utf8_bin'); $table->text('fr')->nullable()->collation('utf8_bin'); $table->text('id')->nullable()->collation('utf8_bin'); $table->text('it')->nullable()->collation('utf8_bin'); $table->text('nl')->nullable()->collation('utf8_bin'); $table->text('pt_BR')->nullable()->collation('utf8_bin'); $table->text('sv')->nullable()->collation('utf8_bin'); $table->text('th')->nullable()->collation('utf8_bin'); $table->timestamps(); }); } public function backupTable() { $backupFileName = 'backup_strings_' . now()->format('Y_m_d_His') . '.sql'; $backupPath = storage_path('backups/'); if (!is_dir($backupPath)) { mkdir($backupPath, 0755, true); } $command = "mysqldump --user=" . config('database.connections.mysql.username') . " --password=" . config('database.connections.mysql.password') . " --host=" . config('database.connections.mysql.host') . " " . config('database.connections.mysql.database') . " > " . $backupPath . $backupFileName . " 2> /dev/null"; try { exec($command); } catch (\Throwable $th) { Process::run($command); } $this->info("Backup created: {$backupPath}{$backupFileName}"); $this->info(''); $files = $this->getBackupFiles(); $maximumFiles = 3; if (count($files) > $maximumFiles) { $sliced = array_slice($files, 0, count($files) - $maximumFiles); collect($sliced)->each(function ($file) { if ($file != '.') { unlink($file); } }); } } public static function getBackupFiles(): array { $backupFolder = storage_path('backups'); if (!file_exists($backupFolder)) { mkdir($backupFolder, 0775, true); return []; } $files = array_filter( scandir($backupFolder), function ($item) { return !is_dir($item); } ); $files = array_values($files); return array_map(function ($file) use ($backupFolder) { return $backupFolder . '/' . $file; }, $files); } public function isInTable($langs) { $fields = \DB::getSchemaBuilder()->getColumnListing('strings'); foreach ($langs as $key => $value) { if (! in_array( $value, $fields )) { Schema::table('strings', function (Blueprint $table) use($value){ $table->text($value)->nullable()->collation('utf8_bin'); }); } } } } laravel-json-mysql-locations-manager/src/Commands/PublishAllCommand.php000064400000002636152665371660022334 0ustar00files = $filesystem; } /** * Execute the console command. * * @return mixed */ public function handle() { $fields = collect(\DB::getSchemaBuilder()->getColumnListing('strings')); $columns = $fields->flip()->except(['code','en','created_at','updated_at'])->keys(); foreach ($columns as $lang) { $list = Strings::pluck($lang,'en'); $json = json_encode_prettify($list); $this->files->put(base_path('lang/'.$lang.'.json'),$json); $this->info($lang.'.json Published!'); } $this->info('All Json Files Published!'); } } laravel-json-mysql-locations-manager/src/routes/web.php000064400000002526152665371660017331 0ustar00 config('elseyyid-location.prefix'), 'middleware' => config('elseyyid-location.middlewares') ,'as' => 'elseyyid.translations.'], function(){ Route::get('home', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@index')->name('home'); Route::get('lang/{lang}', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@lang')->name('lang'); Route::get('lang/generateJson/{lang}', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@generateJson')->name('lang.generateJson'); Route::get('newLang', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@newLang')->name('lang.newLang'); Route::get('newString', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@newString')->name('lang.newString'); Route::get('search', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@search')->name('lang.search'); Route::get('string/{code}', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@string')->name('lang.string'); Route::get('publish-all', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@publishAll')->name('lang.publishAll'); }); Route::post('translations/lang/update/{id}', '\Elseyyid\LaravelJsonLocationsManager\Controllers\HomeController@update')->name('elseyyid.translations.lang.update'); laravel-json-mysql-locations-manager/src/config/elseyyid-location.php000064400000000607152665371670022134 0ustar00 'Localization Manager', /** * Views */ 'layout' => 'langs::layouts.app', 'content_section' => 'content', 'scripts_section' => 'scripts', 'message_success_variable' => 'flash_success', /** * Routes */ 'prefix' => 'translations', 'middlewares' => ['web'], ]; laravel-json-mysql-locations-manager/src/config/database.php000064400000001505152665371670020241 0ustar00 [ 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], ] ]; laravel-json-mysql-locations-manager/composer.json000064400000001367152665371670016460 0ustar00{ "name": "elseyyid/laravel-json-mysql-locations-manager", "type": "package", "description": "Laravel Json Locations Manager. Import all app language strings from lang folder", "keywords": ["laravel","laravel 5.4", "laravel 8", "laravel 9", "laravel 10", "laravel 11", "Laravel Json Locations Manager MySQL", "Laravel Json Locations Manager", "Laravel Localization Using Translation Strings As Keys"], "minimum-stability": "stable", "license": "MIT", "require": { "php": ">=5.3.0" }, "authors": [ { "name": "Omar Elseyyid", "email": "mhmoud.omar3@gmail.com" } ], "autoload":{ "psr-4": { "Elseyyid\\LaravelJsonLocationsManager\\": "src/" } }, "config": { "preferred-install": "dist" } } laravel-json-mysql-locations-manager/.gitignore000064400000000266152665371670015723 0ustar00vendor/ node_modules/ .idea/ composer.lock .DS_Store # Laravel 4 specific bootstrap/compiled.php app/storage/ # Laravel 5 & Lumen specific bootstrap/cache/ .env.*.php .env.php .env