134 lines
4.5 KiB
PHP
134 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Constant\Constant;
|
|
use App\Models\Post;
|
|
use App\Models\Sangh;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Api\ApiController;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class BaseController extends ApiController
|
|
{
|
|
/**
|
|
* Boolean status code
|
|
*/
|
|
const STATUS_ZERO = 0;
|
|
const STATUS_ONE = 1;
|
|
const STATUS_TRUE = true;
|
|
const STATUS_FALSE = false;
|
|
const STATUS_ACTIVE = 'active';
|
|
const STATUS_INACTIVE = 'inactive';
|
|
const STATUS_DELETE = 'delete';
|
|
|
|
/**
|
|
* HTTP status code
|
|
*/
|
|
const HTTP_STATUS_CODE_200 = 200; // 200: OK. The standard success code and default option.
|
|
const HTTP_STATUS_CODE_201 = 201; // 201: Object created. Useful for the store actions.
|
|
const HTTP_STATUS_CODE_204 = 204; // 204: No content. When an action was executed successfully, but there is no content to return.
|
|
const HTTP_STATUS_CODE_206 = 206; // 206: Partial content. Useful when you have to return a paginated list of resources.
|
|
const HTTP_STATUS_CODE_400 = 400; // 400: Bad request. The standard option for requests that fail to pass validation.
|
|
const HTTP_STATUS_CODE_401 = 401; // 401: Unauthorized. The user needs to be authenticated.
|
|
const HTTP_STATUS_CODE_403 = 403; // 403: Forbidden. The user is authenticated, but does not have the permissions to perform an action.
|
|
const HTTP_STATUS_CODE_422 = 422; // 403: Forbidden. The user is authenticated, but does not have the permissions to perform an action.
|
|
const HTTP_STATUS_CODE_404 = 404; // 403: Forbidden. The user is authenticated, but does not have the permissions to perform an action.
|
|
const HTTP_STATUS_CODE_500 = 500; // 404: Not found. This will be returned automatically by Laravel when the resource is not found.
|
|
const HTTP_STATUS_CODE_503 = 503; // 500: Internal server error. Ideally you're not going to be explicitly returning this, but if something unexpected breaks, this is what your user is going to receive.
|
|
|
|
|
|
public function getInformativePage(Request $request)
|
|
{
|
|
try {
|
|
$page = $request->page;
|
|
$response['content'] = trans('informative-page.'.$page);
|
|
|
|
return $this->respond(['content' => $response['content'], 'status_code' => $this->getStatusCode()]);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
}
|
|
|
|
public function getLandingPage()
|
|
{
|
|
try {
|
|
return view('web.landing');
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
}
|
|
}
|
|
|
|
public function getLandingPageWithMeta($id)
|
|
{
|
|
$post = [];
|
|
$createdBy = "";
|
|
|
|
try {
|
|
$post = Post::with([
|
|
'tagUsers:id,name,avatar',
|
|
'postImages',
|
|
'category',
|
|
'postMention',
|
|
'createdBy:id,name,avatar,created_at,updated_at',
|
|
'updatedBy:id,name,avatar,created_at,updated_at'
|
|
])->find($id);
|
|
|
|
if (!empty(request()->type) && request()->type == Constant::STATUS_ONE) {
|
|
$createdBy = $post->createdBy->name;
|
|
} else if (!empty(request()->type) && request()->type == Constant::STATUS_THREE) {
|
|
$createdById = $post->created_by;
|
|
$createdBy = Sangh::where('id', $createdById)->value('name');
|
|
} else {
|
|
$createdBy = env('APP_NAME');
|
|
}
|
|
|
|
return view('web.landing-new', compact('post', 'createdBy'));
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
}
|
|
}
|
|
|
|
public function getTermsAndConditionsPage()
|
|
{
|
|
try {
|
|
return view('web.terms-and-conditions');
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
}
|
|
}
|
|
|
|
public function getPrivacyPolicyPage()
|
|
{
|
|
try {
|
|
return view('web.privacy-policy');
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
}
|
|
}
|
|
|
|
public function getContributionPage()
|
|
{
|
|
try {
|
|
return view('web.contribution');
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
}
|
|
}
|
|
|
|
public function getAppleAppSiteID()
|
|
{
|
|
try {
|
|
return response(view('web.apple-app-site-association'), 200, ['Content-Type' => 'application/json']);
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
}
|
|
}
|
|
}
|