Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,53 @@

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\Admin\ProviderService;
use App\Services\Admin\ContactFormService;
use App\Services\Admin\EditProfileService;
use App\Http\Requests\Admin\EditProfileRequest;
use App\Http\Requests\Admin\EditProviderRequest;
use App\Services\Admin\editProfileService;
use App\Services\Admin\getAllProvidersService;
use App\Services\Admin\DeleteContactMessageService;
use App\Services\Admin\getAllContactMessagesService;
use App\Services\Admin\AdminEditProviderProfileService;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class AdminFunctionsController extends Controller
class AdminController extends Controller
{
public function getProviders()
{
try {
$providers = getAllProvidersService::getAll();
$providers = ProviderService::getAll();

return $this->messageResponse(true, "Providers retrieved successfully", 200, $providers);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to retrieve providers", 500);
}
}

public function getContactMessages()
{
try {
$messages = getAllContactMessagesService::getAll();

return $this->messageResponse(true, "Messages retrieved successfully", 200, $messages);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to retrieve messages", 500);
}
}

public function editProvider(EditProviderRequest $request, $id)
{
try {
AdminEditProviderProfileService::editProfile($id, $request->validated());
ProviderService::editProfile($id, $request->validated());

return $this->messageResponse(true, "Profile updated successfully", 200);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to update profile", 500);
}
}


public function editProfile(EditProfileRequest $request)
public function getContactMessages()
{
try {
editProfileService::editProfile($request->validated());
$messages = ContactFormService::getAll();

return $this->messageResponse(true, "Profile updated successfully", 200);
return $this->messageResponse(true, "Messages retrieved successfully", 200, $messages);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to update profile", 500);
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to retrieve messages", 500);
}
}

public function deleteMessage($id)
{
try {
DeleteContactMessageService::delete($id);
ContactFormService::delete($id);

return $this->messageResponse(true, "Message deleted successfully", 200);
} catch (ModelNotFoundException $e) {
Expand All @@ -72,4 +57,15 @@ public function deleteMessage($id)
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to delete message", 500);
}
}

public function editProfile(EditProfileRequest $request)
{
try {
EditProfileService::editProfile($request->validated());

return $this->messageResponse(true, "Profile updated successfully", 200);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, $e->getMessage(), "Failed to update profile", 500);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?php

namespace App\Http\Controllers\Clients;
namespace App\Http\Controllers\Client;

use App\Http\Controllers\Controller;
use App\Services\Client\ClientDashboardService;
use App\Services\Client\GeneratingReportService;
use App\Services\Client\ClientEditProfileService;
use App\Services\Client\ClientService;
use App\Http\Requests\Client\EditProfileRequest;

class ClientFunctionsController extends Controller
class ClientController extends Controller
{
public function generateReport($id)
{
Expand All @@ -18,7 +16,7 @@ public function generateReport($id)
return $this->messageResponse(false, "Route ID not provided", 400, null);
}

$report = GeneratingReportService::generateReport($id);
$report = ClientService::generateReport($id);
return $this->messageResponse(true, "Report Generated", 200, $report);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, "Failed to generate report ", $e->getMessage(), 500);
Expand All @@ -28,7 +26,7 @@ public function generateReport($id)
public function editProfile(EditProfileRequest $request)
{
try {
ClientEditProfileService::editProfile($request->validated());
ClientService::editProfile($request->validated());

return $this->messageResponse(true, "Profile updated successfully", 200);
} catch (\Exception $e) {
Expand All @@ -39,7 +37,7 @@ public function editProfile(EditProfileRequest $request)
public function getDashboardData($id)
{
try {
$dashboardData = ClientDashboardService::getDashboardData($id);
$dashboardData = ClientService::getDashboardData($id);
return $this->messageResponse(true, "Dashboard data fetched successfully", 200, $dashboardData);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, "Failed to fetch dashboard data", $e->getMessage(), 500);
Expand Down

This file was deleted.

67 changes: 67 additions & 0 deletions amp-laravel/app/Http/Controllers/Common/IotController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace App\Http\Controllers\Common;

use App\Http\Controllers\Controller;

use Throwable;
use InvalidArgumentException;
use App\Services\IotService;
use App\Http\Requests\Client\ClientRequestMetric;
use App\Http\Requests\Client\ClientRequestCheckin;
use App\Http\Requests\Provider\ProviderRequestLine;
use App\Http\Requests\Provider\ProviderRequestCheckin;

class IotController extends Controller
{
// Master Check In
public function masterCheckin(ProviderRequestCheckin $request)
{
try {
$data = IotService::masterCheckin($request->validated());
return $this->messageResponse(true, "Master checked in successfully", 200, $data);
} catch (Throwable $e) {
return $this->errorMessageResponse(false, "Master checkin failed", $e->getMessage(), 500);
}
}

// Slave Check In
public function slaveCheckin(ClientRequestCheckin $request)
{
try {
$slave = IotService::slaveCheckin($request->validated());

return $this->messageResponse(true, "Slave Checkin Successful", 200, $slave);
} catch (InvalidArgumentException $e) {
return $this->errorMessageResponse(false, 'Invalid Input', $e->getMessage(), 422);
} catch (Throwable $e) {
return $this->errorMessageResponse(false, "Slave checkin failed", $e->getMessage(), 500);
} catch (\Exception $e) {
return $this->errorMessageResponse(false, 'Unexpected error', $e->getMessage(), 500);
}
}

// Slave Metrics
public function slaveMetrics(ClientRequestMetric $request)
{
try {
$metric = IotService::addMetrics($request->validated());
return $this->messageResponse(true, "Slave metric stored", 200, $metric);
} catch (InvalidArgumentException $e) {
return $this->errorMessageResponse(false, 'Invalid Input', $e->getMessage(), 422);
} catch (Throwable $e) {
return $this->errorMessageResponse(false, "Metric save failed", $e->getMessage(), 500);
}
}

// Master Lines
public function masterLines(ProviderRequestLine $request)
{
try {
$line = IotService::addLines($request->validated());
return $this->messageResponse(true, "Master lines data saved", 200, $line);
} catch (Throwable $e) {
return $this->errorMessageResponse(false, "Failed to save master lines", $e->getMessage(), 500);
}
}
}
21 changes: 0 additions & 21 deletions amp-laravel/app/Http/Controllers/Common/LinesController.php

This file was deleted.

24 changes: 0 additions & 24 deletions amp-laravel/app/Http/Controllers/Common/MetricsController.php

This file was deleted.

This file was deleted.

Loading
Loading