修复文章查看数为空保存报错

This commit is contained in:
Edward Yang 2023-02-11 20:37:07 +08:00
parent 63638f9588
commit f2d7f76ab9
3 changed files with 7 additions and 5 deletions

View File

@ -71,10 +71,10 @@ class PageRepo
}
$page->fill([
'page_category_id' => (int) ($data['page_category_id'] ?? 0),
'position' => $data['position'] ?? 0,
'active' => $data['active'] ?? true,
'author' => $data['author'] ?? true,
'views' => $data['views'] ?? 0,
'position' => (int) ($data['position'] ?? 0),
'active' => (bool) ($data['active'] ?? true),
'author' => (bool) ($data['author'] ?? true),
'views' => (int) ($data['views'] ?? 0),
]);
$page->saveOrFail();

View File

@ -155,6 +155,7 @@ class Plugin implements Arrayable, \ArrayAccess
public function getLocaleName(): string
{
$currentLocale = locale();
return is_array($this->name) ? ($this->name[$currentLocale] ?? '') : (string) $this->name;
}
@ -166,6 +167,7 @@ class Plugin implements Arrayable, \ArrayAccess
public function getLocaleDescription(): string
{
$currentLocale = locale();
return is_array($this->description) ? ($this->description[$currentLocale] ?? '') : (string) $this->description;
}

View File

@ -22,7 +22,7 @@ class CustomerDiscountService
public static function getTotal(CheckoutService $checkout)
{
$totalService = $checkout->totalService;
$customer = current_customer();
$customer = current_customer();
if (empty($customer)) {
return null;
}