Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
copyrenzhe committed Apr 5, 2017
1 parent 60b5acd commit acb30a4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/SiteMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Console\Commands;

use App\Events\Event;
use Event;
use App\Events\MailPostEvent;
use Illuminate\Console\Command;

Expand Down
16 changes: 7 additions & 9 deletions app/Http/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

namespace App\Http\Controllers;

use App\Events\NovelView;
use App\Events\RepairChapterEvent;
use App\Events\RepairNovelEvent;
use App\Models\Chapter;
use App\Models\Novel;
use Event;
use App\Models\User;
use App\Models\Novel;
use App\Models\Chapter;
use App\Models\UserNovel;
use App\Events\NovelView;
use Illuminate\Http\Request;

use App\Http\Requests;
use Illuminate\Support\Facades\Event;
use App\Events\RepairNovelEvent;
use App\Events\RepairChapterEvent;

class BookController extends CommonController
{
Expand Down Expand Up @@ -55,7 +53,7 @@ public function chapter($bookId, $chapterId, $openId='')
}
$prev = Chapter::where('novel_id', $bookId)->where('id', '<', $chapterId)->orderBy('id', 'desc')->first();
$next = Chapter::where('novel_id', $bookId)->where('id', '>', $chapterId)->orderBy('id', 'asc')->first();
Event::fire(new NovelView($chapter));
\Event::fire(new NovelView($chapter));
return view('book.chapter', compact('chapter', 'prev', 'next', 'subList'));
}

Expand Down
24 changes: 11 additions & 13 deletions app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

namespace App\Http\Controllers;

use App\Events\Event;
use App\Events\MailPostEvent;
use Event;
use Cache;
use Session;
use Validator;
use App\Models\Novel;
use App\Models\Author;
use App\Models\Feedback;
use Illuminate\Http\Request;

use App\Http\Requests;
use Illuminate\Support\Facades\Cache;
use App\Events\MailPostEvent;

class IndexController extends CommonController
{
Expand All @@ -26,7 +24,7 @@ public function __construct()

public function index()
{
$TopNovels = Cache::remember('TopNovels', 60, function() {
$TopNovels = Cache::remember('TopNovels', 60, function () {
return Novel::top()->take(8)->get();
});
$LastNovels = Novel::with('author')->latest()->take(15)->get();
Expand Down Expand Up @@ -65,10 +63,10 @@ public function over()
public function search(Request $request)
{
$keywords = $request->get('keyword');
$authors = Author::where('name', 'like', '%'.$keywords.'%')->pluck('id')->toArray();
$novels = Novel::where('name', 'like', '%'.$keywords.'%')
->orwhereIn('author_id', $authors)->hot()->paginate(30);
$name = "关键词:".$keywords;
$authors = Author::where('name', 'like', '%' . $keywords . '%')->pluck('id')->toArray();
$novels = Novel::where('name', 'like', '%' . $keywords . '%')
->orwhereIn('author_id', $authors)->hot()->paginate(30);
$name = "关键词:" . $keywords;
return view('index.list', compact('name', 'novels'));
}

Expand All @@ -87,17 +85,17 @@ public function postFeedback(Request $request)
'content' => 'required|max:500'
]);

if($validator->fails()) {
if ($validator->fails()) {
return redirect('feedback')
->withInput()
->withErrors($validator);
}

$feedback = Feedback::create($request->input());
if($feedback) {
if ($feedback) {
Session::flash('flash_message', '提交成功!');
$title = '收到新的意见反馈';
Event::fire(new MailPostEvent('feedback', $title, $feedback->toArray()));
\Event::fire(new MailPostEvent('feedback', $title, $feedback->toArray()));
return redirect('/');
} else {
Session::flash('flash_message', '提交失败!');
Expand Down
2 changes: 1 addition & 1 deletion config/wechat.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* file:日志文件位置(绝对路径!!!),要求可写权限
*/
'log' => [
'level' => env('WECHAT_LOG_LEVEL', 'debug'),
'level' => env('WECHAT_LOG_LEVEL', 'error'),
'file' => env('WECHAT_LOG_FILE', storage_path('logs/wechat.log')),
],

Expand Down

0 comments on commit acb30a4

Please sign in to comment.