. */ namespace App\Http\Controllers\Api\Admin; use App\Http\Controllers\Controller; use App\Account; use Illuminate\Http\Request; class AccountDictionaryController extends Controller { public function index(int $accountId) { return Account::findOrFail($accountId)->dictionary; } public function show(int $accountId, string $key) { return Account::findOrFail($accountId)->dictionaryEntries()->where('key', $key)->first(); } public function set(Request $request, int $accountId, string $key) { $request->validate([ 'value' => 'required' ]); $account = Account::findOrFail($accountId); $result = $account->setDictionaryEntry($key, $request->get('value')); if (function_exists('accountServiceAccountEditedHook')) { $account->refresh(); accountServiceAccountEditedHook($request, $account); } return $result; } public function destroy(int $accountId, string $key) { return Account::findOrFail($accountId)->dictionaryEntries()->where('key', $key)->delete(); } }