Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
baijunyao committed Dec 28, 2019
2 parents c2a616f + 6c5f1ed commit d764df5
Show file tree
Hide file tree
Showing 86 changed files with 3,431 additions and 675 deletions.
71 changes: 71 additions & 0 deletions app/Console/Commands/Upgrade/V6_8_0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Console\Commands\Upgrade;

use App\Models\Config;
use Illuminate\Console\Command;

class V6_8_0 extends Command
{
protected $signature = 'upgrade:v6.8.0';
protected $description = 'Upgrade to v6.8.0';

public function __construct()
{
parent::__construct();
}

public function handle()
{
Config::insert([
[
'id' => 188,
'name' => 'bjyblog.social_links.github',
'value' => '',
'created_at' => '2019-12-22 23:55:00',
'updated_at' => '2019-12-22 23:55:00',
'deleted_at' => null,
],
[
'id' => 189,
'name' => 'bjyblog.social_links.gitee',
'value' => '',
'created_at' => '2019-12-22 23:55:00',
'updated_at' => '2019-12-22 23:55:00',
'deleted_at' => null,
],
[
'id' => 190,
'name' => 'bjyblog.social_links.zhihu',
'value' => '',
'created_at' => '2019-12-22 23:55:00',
'updated_at' => '2019-12-22 23:55:00',
'deleted_at' => null,
],
[
'id' => 191,
'name' => 'bjyblog.social_links.weibo',
'value' => '',
'created_at' => '2019-12-22 23:55:00',
'updated_at' => '2019-12-22 23:55:00',
'deleted_at' => null,
],
[
'id' => 192,
'name' => 'bjyblog.social_links.upyun',
'value' => '',
'created_at' => '2019-12-22 23:55:00',
'updated_at' => '2019-12-22 23:55:00',
'deleted_at' => null,
],
[
'id' => 193,
'name' => 'bjyblog.link_target',
'value' => '_blank',
'created_at' => '2019-12-25 23:06:00',
'updated_at' => '2019-12-25 23:06:00',
'deleted_at' => null,
],
]);
}
}
5 changes: 5 additions & 0 deletions app/Http/Controllers/Admin/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public function socialShare()
return view('admin.config.socialShare');
}

public function socialLinks()
{
return view('admin.config.socialLinks');
}

public function commentAudit()
{
return view('admin.config.commentAudit');
Expand Down
22 changes: 22 additions & 0 deletions app/Http/Resources/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

namespace App\Http\Resources;

/**
* @mixin \App\Models\Comment
*/
class Comment extends Base
{
public function toArray($request)
{
return [
'id' => $this->id,
'content' => $this->content,
'is_audited' => $this->is_audited,
'socialite_user' => [
'id' => $this->socialiteUser->id,
'name' => $this->socialiteUser->name,
],
'article' => [
'id' => $this->article->id,
'title' => $this->article->title,
],
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'deleted_at' => $this->deleted_at,
];
}
}
4 changes: 4 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public function boot()
$local = config('app.locale');
app('translator')->setLocale($local);
Carbon::setLocale($local);

Carbon::serializeUsing(function (Carbon $timestamp) {
return $timestamp->format('Y-m-d H:i:s');
});
}

/**
Expand Down
16 changes: 13 additions & 3 deletions app/Providers/ComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ public function boot()
return !empty($socialiteClient->client_id) && !empty($socialiteClient->client_secret);
});

$homeFootColNumber = array_filter(config('bjyblog.social_links')) === [] ? 4 : 3;

// 分配数据
$assign = compact('category', 'tag', 'topArticle', 'friendshipLink', 'nav', 'qqQunArticle', 'socialiteClients');
$assign = compact('category', 'tag', 'topArticle', 'friendshipLink', 'nav', 'qqQunArticle', 'socialiteClients', 'homeFootColNumber');
$view->with($assign);
});

Expand All @@ -146,10 +148,18 @@ public function boot()
$comment->sub_content = strip_tags($comment->content);

if (mb_strlen($comment->sub_content) > 10) {
$comment->sub_content = Str::substr($comment->sub_content, 0, 40);
if (config('app.locale') === 'zh-CN') {
$comment->sub_content = Str::substr($comment->sub_content, 0, 40);
} else {
$comment->sub_content = Str::words($comment->sub_content, 10, '');
}
}

$comment->article->sub_title = Str::substr($comment->article->title, 0, 20);
if (config('app.locale') === 'zh-CN') {
$comment->article->sub_title = Str::substr($comment->article->title, 0, 20);
} else {
$comment->article->sub_title = Str::words($comment->article->title, 5, '');
}

return $comment;
});
Expand Down
Loading

0 comments on commit d764df5

Please sign in to comment.