İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get a specific setting value for mobile.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $key
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function get(Request $request, $key)
|
||||
{
|
||||
$allowedKeys = [
|
||||
'unit_kgmetc',
|
||||
'akt_status',
|
||||
];
|
||||
|
||||
if (!in_array($key, $allowedKeys)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Unauthorized or invalid key'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$value = setting($key);
|
||||
|
||||
$decoded = json_decode($value, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE && (is_array($decoded) || is_object($decoded))) {
|
||||
$data = $decoded;
|
||||
} else {
|
||||
$data = $value;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'key' => $key,
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all common settings.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function common()
|
||||
{
|
||||
$keys = [
|
||||
'project_name',
|
||||
'project_name_ru',
|
||||
'project_number',
|
||||
'company_code',
|
||||
'row_count',
|
||||
'summary_mails',
|
||||
'register_creator_file_name_pattern',
|
||||
'register_creator_start_row',
|
||||
'register_creator_path',
|
||||
'register_creator_column_based',
|
||||
'hand_over_zone_column',
|
||||
'tp_register_creator_path',
|
||||
'main_subcontractor',
|
||||
'cron_job_batch_process_count',
|
||||
'cron_job_period',
|
||||
'repair_table_target_rate',
|
||||
'ndt_limit',
|
||||
'ndt_wdi',
|
||||
'repair_limit',
|
||||
'repair_wdi',
|
||||
'WelderQualitificationStatusExpiredDate',
|
||||
'WelderQualitificationStatusRemaningDays',
|
||||
'ndt_date_validation_active',
|
||||
'header_color',
|
||||
'DevExpress_Theme',
|
||||
'pdf_template_path',
|
||||
'handover_control_count'
|
||||
];
|
||||
|
||||
$data = [];
|
||||
foreach ($keys as $key) {
|
||||
$value = setting($key);
|
||||
|
||||
// Attempt to decode JSON if it looks like an array/object
|
||||
$decoded = json_decode($value, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE && (is_array($decoded) || is_object($decoded))) {
|
||||
$data[$key] = $decoded;
|
||||
} else {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user