| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/app.machinox.in/app/Http/Controllers/Admin/ |
Upload File : |
<?php
namespace App\Http\Controllers\Admin;
use App\Actions\Admin\MachineModelAction;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\MachineModelRequest;
use App\Http\Requests\Admin\MachineModelImageRequest;
use Exception;
use Illuminate\Http\Request;
use App\Models\MachineModel;
use App\Services\RedisService;
use Illuminate\Support\Facades\Redis;
class MachineModelController extends Controller
{
public function SetInfo(MachineModelRequest $request, MachineModelAction $action, $modelId = null)
{
try {
$response = $action->execute($request, $modelId);
$redis = new RedisService();
if ($redis->isEnabled()) {
$redis->delete("machine_type:{$response->id}:models");
}
return $this->sendSuccess($response->message, ['id' => $response->id]);
} catch (Exception $e) {
return response()->json(['status' => 'error', 'message' => $e->getMessage()], 500);
}
}
public function GetList(Request $request, $typeId)
{
try {
$list = MachineModel::GetMachineModels($request, $typeId);
return $this->sendSuccess(trans('messages.OK'), $list);
} catch (Exception $th) {
return $this->sendError($th->getMessage());
}
}
public function GetInfo($id)
{
try {
$info = MachineModel::with('type:id,name')->findOrFail($id);
return $this->sendSuccess(trans('messages.OK'), $info);
} catch (Exception $th) {
return $this->sendError($th->getMessage());
}
}
public function Destroy($modelId, MachineModelAction $action)
{
try {
$response = $action->destroy($modelId);
$redis = new RedisService();
if ($redis->isEnabled()) {
$redis->delete("machine_type:{$modelId}:models");
}
return $this->sendSuccess($response);
} catch (Exception $e) {
return response()->json(['status' => 'error', 'message' => $e->getMessage()], 500);
}
}
public function SetMachineModelImage(MachineModelImageRequest $request, MachineModelAction $action, $modelId)
{
$response = $action->upload($request, $modelId);
return $this->sendSuccess($response->message,['path' => $response->Path], );
}
}