mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Fixed some bugs and added a proper home page
This commit is contained in:
43
app/Http/Controllers/HomeController.php
Normal file
43
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Oxbow\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Oxbow\Http\Requests;
|
||||
use Oxbow\Http\Controllers\Controller;
|
||||
use Oxbow\Repos\BookRepo;
|
||||
use Oxbow\Services\ActivityService;
|
||||
use Oxbow\Services\Facades\Activity;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
||||
protected $activityService;
|
||||
protected $bookRepo;
|
||||
|
||||
/**
|
||||
* HomeController constructor.
|
||||
* @param ActivityService $activityService
|
||||
* @param BookRepo $bookRepo
|
||||
*/
|
||||
public function __construct(ActivityService $activityService, BookRepo $bookRepo)
|
||||
{
|
||||
$this->activityService = $activityService;
|
||||
$this->bookRepo = $bookRepo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the homepage.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$books = $this->bookRepo->getAll();
|
||||
$activity = $this->activityService->latest();
|
||||
return view('home', ['books' => $books, 'activity' => $activity]);
|
||||
}
|
||||
|
||||
}
|
@ -79,12 +79,9 @@ Route::group(['middleware' => 'auth'], function() {
|
||||
// Search
|
||||
Route::get('/pages/search/all', 'PageController@searchAll');
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('home');
|
||||
});
|
||||
Route::get('/home', function () {
|
||||
return view('home');
|
||||
});
|
||||
// Other Pages
|
||||
Route::get('/', 'HomeController@index');
|
||||
Route::get('/home', 'HomeController@index');
|
||||
|
||||
|
||||
});
|
||||
|
@ -19,7 +19,6 @@ class ActivityService
|
||||
$this->user = Auth::user();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add activity data to database.
|
||||
* @para Entity $entity
|
||||
@ -54,4 +53,15 @@ class ActivityService
|
||||
$this->activity->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the latest activity.
|
||||
* @param int $count
|
||||
* @param int $page
|
||||
*/
|
||||
public function latest($count = 20, $page = 0)
|
||||
{
|
||||
return $this->activity->orderBy('created_at', 'desc')
|
||||
->skip($count*$page)->take($count)->get();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user