Replaced Moment with Carbon #84

Merged
Ghost merged 148 commits from develop into beta 2022-09-22 05:53:36 +02:00
4 changed files with 32 additions and 9 deletions
Showing only changes of commit 91aa2703b6 - Show all commits

View file

@ -5,18 +5,41 @@ namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Assets\FileUploadService;
use App\Interfaces\MemberRepositoryInterface;
use App\Services\Data\SettingsService;
class FileUploadAPIController extends Controller
{
protected $upload;
protected $member;
protected $settings;
public function __construct(FileUploadService $fileUploadService)
{
$this->upload = $fileUploadService;
public function __construct(
FileUploadService $fileUploadService,
MemberRepositoryInterface $memberRepo,
SettingsService $settingsService
) {
$this->upload = $fileUploadService;
$this->member = $memberRepo;
$this->settings = $settingsService;
}
public function upload(Request $request, $type = null)
{
return $this->upload->handleFile($request, $type);
$result = $this->upload->handleFile($request, $type);
//update configs for specfic uploads
switch ($request['source']) {
case 'avatar-upload':
$member = [];
$member = session('member');
$member['avatar'] = $result['filePath'];
$member = (object) $member;
$this->member->update($member);
break;
case 'background-upload':
$this->settings->updateGlobalData('background', $result['filePath']);
break;
}
return $result;
}
}

View file

@ -54,10 +54,10 @@ class MemberRepository implements MemberRepositoryInterface
public function update($member)
{
//TODO: need to add member avatar updating
$index = findIndex($this->folks, ['id' => $member->id]);
$this->folks[$index]['handle'] = $member->handle;
$this->folks[$index]['email'] = $member->email;
$this->folks[$index]['avatar'] = $member->avatar;
$this->folks[$index]['updated'] = Carbon::now();
//save new folks file
$this->docs::writeSettings($this->folks, env('FOLKS_PATH'));
@ -77,7 +77,7 @@ class MemberRepository implements MemberRepositoryInterface
'handle' => $found['handle'],
'email' => $found['email'],
'role' => $found['role'],
'avatar' => $found['avi'],
'avatar' => $found['avatar'],
'key' => $found['key'],
'secret' => $found['secret'],
];

View file

@ -23,8 +23,8 @@ class FileUploadService
case 'jpg':
case 'png':
case 'gif':
if (isset($options["source"])) {
if ($options["source"] == "avatar-upload") {
if (isset($request["source"])) {
if ($request["source"] == "avatar-upload") {
$filesPath = '/assets/images/user/' . $path . '/';
//Member::updateData('avi', $filesPath . $file->getClientFileName());
} else {

View file

@ -2,7 +2,7 @@
{
"id": "",
"handle": "",
"avi": "/assets/images/global/default-avi.png",
"avatar": "/assets/images/global/default-avi.png",
"email": "",
"password": "",
"key": "",