Skip to content

Commit

Permalink
Merge pull request #5 from centrust/v3
Browse files Browse the repository at this point in the history
Add LocalizationController and update namespaces
  • Loading branch information
centrust committed Dec 16, 2023
2 parents 63f48d9 + dcfeb2c commit bcc0764
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/Http/LocalizationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Centrust\NovaLocalization\Http;

use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

class LocalizationController extends Controller
{


public function changeLanguage(Request $request)
{
$User = $request->user();

$User::update( ['locale' => $request->language]);

return redirect()->to(config('app.url').config('nova.path'));

}
}
4 changes: 2 additions & 2 deletions src/Nova/NovaLocalizationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NovaLocalizationResource extends Resource
/**
* The model the resource corresponds to.
*
* @var class-string<\ECentrust\NovaLocalization\Models\Localizatio>
* @var class-string<\Centrust\NovaLocalization\Models\Localization>
*/
public static $model = Localization::class;

Expand Down Expand Up @@ -79,7 +79,7 @@ public function fields(NovaRequest $request)
})->onlyOnIndex(),
Text::make('Group')->sortable()->readonly(),

new Panel(_tran('Localizations'), $this->LocalizationFileds()),
new Panel(_tran('Localizations'), $this->LocalizationFileds()),

];
}
Expand Down
3 changes: 3 additions & 0 deletions src/NovaLocalizationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Centrust\NovaLocalization;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Menu\Menu;
use Laravel\Nova\Menu\MenuItem;
Expand Down Expand Up @@ -53,5 +54,7 @@ public function bootingPackage()

return $menu;
});

Route::get('change-language/{language}', [\Centrust\NovaLocalization\Http\LocalizationController::class, 'changeLanguage']);
}
}

0 comments on commit bcc0764

Please sign in to comment.