FleetCart/Modules/Translation/Http/Controllers/Admin/TranslationController.php

42 lines
1002 B
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace Modules\Translation\Http\Controllers\Admin;
2023-12-03 14:07:47 +00:00
use Illuminate\Http\Response;
2023-06-11 12:14:03 +00:00
use Modules\Translation\Entities\Translation;
class TranslationController
{
/**
* Display a listing of the resource.
*
2023-12-03 14:07:47 +00:00
* @return Response
2023-06-11 12:14:03 +00:00
*/
public function index()
{
$translations = Translation::retrieve();
return view('translation::admin.translations.index', compact('translations'));
}
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
/**
* Update the specified resource in storage.
*
* @param string $key
2023-12-03 14:07:47 +00:00
*
* @return Response
2023-06-11 12:14:03 +00:00
*/
public function update($key)
{
Translation::firstOrCreate(['key' => $key])
->translations()
->updateOrCreate(
['locale' => request('locale')],
['value' => request('value', '')]
);
2023-12-03 14:07:47 +00:00
return trans('admin::messages.resource_updated', ['resource' => trans('translation::translations.translation')]);
2023-06-11 12:14:03 +00:00
}
}