v2board/app/Http/Controllers/TutorialController.php

55 lines
1.7 KiB
PHP
Raw Normal View History

2019-11-23 01:41:47 +08:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\User;
2020-01-02 21:49:04 +08:00
use App\Models\Tutorial;
2019-11-23 01:41:47 +08:00
class TutorialController extends Controller
{
2019-11-23 13:17:33 +08:00
public function getSubscribeUrl (Request $request) {
2019-11-23 01:41:47 +08:00
$user = User::find($request->session()->get('id'));
return response([
2019-11-23 13:27:38 +08:00
'data' => [
2019-11-23 23:32:44 +08:00
'subscribe_url' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']
2019-11-23 13:27:38 +08:00
]
2019-11-23 01:41:47 +08:00
]);
}
2019-11-23 13:17:33 +08:00
public function getAppleID (Request $request) {
2019-11-23 01:43:38 +08:00
$user = User::find($request->session()->get('id'));
2019-11-23 15:05:46 +08:00
if ($user->expired_at < time()) {
2019-11-23 01:43:38 +08:00
return response([
2019-11-23 13:31:20 +08:00
'data' => [
]
2019-11-23 01:44:02 +08:00
]);
2019-11-23 01:43:38 +08:00
}
2019-11-23 15:05:02 +08:00
return response([
'data' => [
'apple_id' => config('v2board.apple_id'),
'apple_id_password' => config('v2board.apple_id_password')
]
]);
2019-11-23 01:41:47 +08:00
}
2020-01-02 21:49:04 +08:00
public function fetch (Request $request) {
$tutorial = Tutorial::select(['title', 'description', 'icon'])->get();
2020-01-02 21:52:20 +08:00
$response = [
'data' => [
'tutorials' => $tutorial,
'subscribe_url' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']
]
];
$user = User::find($request->session()->get('id'));
if ($user->expired_at > time()) {
$response['data']['apple_id'] = [
'apple_id' => config('v2board.apple_id'),
'apple_id_password' => config('v2board.apple_id_password')
];
}
return response($response);
2020-01-02 21:49:04 +08:00
}
2019-11-23 01:41:47 +08:00
}