Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/DomainsController.php
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | class DomainsController extends Controller | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function edit($id) | public function edit($id) | ||||
{ | { | ||||
return $this->errorResponse(404); | return $this->errorResponse(404); | ||||
} | } | ||||
/** | /** | ||||
* Set the domain configuration. | |||||
* | |||||
* @param int $id Domain identifier | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse|void | |||||
*/ | |||||
public function setConfig($id) | |||||
{ | |||||
$domain = Domain::find($id); | |||||
if (empty($domain)) { | |||||
return $this->errorResponse(404); | |||||
} | |||||
// Only owner (or admin) has access to the domain | |||||
if (!$this->guard()->user()->canRead($domain)) { | |||||
return $this->errorResponse(403); | |||||
} | |||||
$errors = $domain->setConfig(request()->input()); | |||||
if (!empty($errors)) { | |||||
return response()->json(['status' => 'error', 'errors' => $errors], 422); | |||||
} | |||||
return response()->json([ | |||||
'status' => 'success', | |||||
'message' => \trans('app.domain-setconfig-success'), | |||||
]); | |||||
} | |||||
/** | |||||
* Store a newly created resource in storage. | * Store a newly created resource in storage. | ||||
* | * | ||||
* @param \Illuminate\Http\Request $request | * @param \Illuminate\Http\Request $request | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function store(Request $request) | public function store(Request $request) | ||||
{ | { | ||||
Show All 23 Lines | public function show($id) | ||||
// Add hash information to the response | // Add hash information to the response | ||||
$response['hash_text'] = $domain->hash(Domain::HASH_TEXT); | $response['hash_text'] = $domain->hash(Domain::HASH_TEXT); | ||||
$response['hash_cname'] = $domain->hash(Domain::HASH_CNAME); | $response['hash_cname'] = $domain->hash(Domain::HASH_CNAME); | ||||
$response['hash_code'] = $domain->hash(Domain::HASH_CODE); | $response['hash_code'] = $domain->hash(Domain::HASH_CODE); | ||||
// Add DNS/MX configuration for the domain | // Add DNS/MX configuration for the domain | ||||
$response['dns'] = self::getDNSConfig($domain); | $response['dns'] = self::getDNSConfig($domain); | ||||
$response['config'] = self::getMXConfig($domain->namespace); | $response['mx'] = self::getMXConfig($domain->namespace); | ||||
// Domain configuration, e.g. spf whitelist | |||||
$response['config'] = $domain->getConfig(); | |||||
// Status info | // Status info | ||||
$response['statusInfo'] = self::statusInfo($domain); | $response['statusInfo'] = self::statusInfo($domain); | ||||
$response = array_merge($response, self::domainStatuses($domain)); | $response = array_merge($response, self::domainStatuses($domain)); | ||||
return response()->json($response); | return response()->json($response); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 240 Lines • Show Last 20 Lines |