. */ 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' ]); return Account::findOrFail($accountId)->setDictionaryEntry($key, $request->get('value')); } public function destroy(int $accountId, string $key) { return Account::findOrFail($accountId)->dictionaryEntries()->where('key', $key)->delete(); } }