Merge pull request #847 from openclassify/vedatakdogan

convert currency function
This commit is contained in:
Fatih Alp 2020-12-02 10:37:05 +03:00 committed by GitHub
commit 9733c8c7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 110 additions and 1 deletions

View File

@ -17,7 +17,9 @@
<div class="card-body">
{% if setting_value('visiosoft.theme.base::price_fields') %}
<div class="d-flex justify-content-between align-items-center">
<b>{{ adv.price }} {{ adv.currency }}</b>
<b>{{ adv.price != '0'
? adv.price.currency()
: trans('visiosoft.module.advs::field.free') }}</b>
</div>
{% endif %}
<div class="d-flex justify-content-between align-items-center text-truncate">

View File

@ -37,6 +37,9 @@ class Currency
$suffix = $this->symbol($currency);
}
if (is_object($number)) {
$number = $number->getValue();
}
$decimal_value = $this->getDecimalValue($number);

View File

@ -2,13 +2,88 @@
namespace App\Exceptions;
use Anomaly\Streams\Platform\Exception\ExceptionIdentifier;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;
class ExceptionHandler extends Handler
{
/**
* The exception instance.
*
* @var Exception
*/
protected $original;
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $internalDontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
protected function prepareException(Exception $e)
{
$this->original = $e;
return parent::prepareException($e); // TODO: Change the autogenerated stub
}
public function render($request, Exception $e)
{
if ($e instanceof AuthenticationException) {
return $this->unauthenticated($request, $e);
}
if ($e instanceof NotFoundHttpException && $redirect = config('streams::404.redirect')) {
return redirect($redirect);
}
return parent::render($request, $e);
}
protected function renderHttpException(HttpExceptionInterface $e)
{
if (env('APP_DEBUG') === true) {
return $this->convertExceptionToResponse($e);
}
$summary = $e->getMessage();
$headers = $e->getHeaders();
$code = $e->getStatusCode();
$name = trans("streams::error.{$code}.name");
$message = trans("streams::error.{$code}.message");
$id = $this->container->make(ExceptionIdentifier::class)->identify($this->original);
if (view()->exists($view = "streams::errors/{$code}")) {
return response()->view($view, compact('id', 'code', 'name', 'message', 'summary'), $code, $headers);
}
return response()->view(
'streams::errors/error',
compact('id', 'code', 'name', 'message', 'summary'),
$code,
$headers
);
}
public function report(Exception $e)
{
@ -18,4 +93,33 @@ class ExceptionHandler extends Handler
parent::report($e);
}
protected function context()
{
try {
return array_filter(
[
'user' => Auth::id(),
'email' => Auth::user() ? Auth::user()->email : null,
'url' => request() ? request()->fullUrl() : null,
'identifier' => $this->container->make(ExceptionIdentifier::class)->identify($this->original),
]
);
} catch (Throwable $e) {
return [];
}
}
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
if ($request->segment(1) === 'admin') {
return redirect()->guest('admin/login');
} else {
return redirect()->guest('login');
}
}
}