Joywork/constructor/Controllers/UserController.php
2026-05-22 21:21:54 +03:00

69 lines
1.6 KiB
PHP

<?php
class UserController extends BaseController
{
public function index()
{
return $this->response($this->query);
}
// public function getOne($userId) {
// if ($userId) {
// }
// }
public function create()
{
// if(isset($users[$userId])) {
// $user = $users[$userId];
// $this->response($user);
// } else {
// $this->response('User not found', false);
// }
return $this->response($this->post);
}
public function update($params)
{
$block_id = $params['block_id'];
// $subblock_id = $params['subblock_id'];
$uploadedFiles = [];
$files = $this->getUploadedFiles(['photo', 'photoArr'], 'folder_name');
foreach ($files as $key => $filePaths) {
if (!empty($filePaths)) {
if (count($filePaths) == 1) {
$uploadedFiles[$key] = [
'path' => $filePaths[0]
];
} else {
$uploadedFiles[$key] = [];
foreach ($filePaths as $path) {
$uploadedFiles[$key][] = [
'path' => $path
];
}
}
}
}
if ($block_id && isset($uploadedFiles['photo'])) {
$blockModel = new BlocksModel();
$blockModel->updatePhotos($block_id, $uploadedFiles['photo']);
}
// if ($subblock_id && isset($uploadedFiles['photoArr'])) {
// $subBlockModel = new SubBlocksModel();
// $subBlockModel->updatePhotos($subblock_id, $uploadedFiles['photoArr']);
// }
$response = [
'postData' => $this->post,
'uploadedFiles' => $uploadedFiles
];
return $this->response($response);
}
}