|
@@ -3,16 +3,22 @@
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use App\Post;
|
|
|
+use App\Repositories\Posts;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
class PostsController extends Controller
|
|
|
{
|
|
|
+ /**
|
|
|
+ * @var \App\Repositories\Posts
|
|
|
+ */
|
|
|
+ protected $posts;
|
|
|
|
|
|
- public function __construct()
|
|
|
+ public function __construct(Posts $posts)
|
|
|
{
|
|
|
$this->middleware('auth')
|
|
|
->except(['index', 'show']);
|
|
|
+ $this->posts = $posts;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -56,9 +62,10 @@ class PostsController extends Controller
|
|
|
*/
|
|
|
public function index(Request $request)
|
|
|
{
|
|
|
- $posts = Post::latest()
|
|
|
- ->filter($request->only(['month', 'year']))
|
|
|
- ->get();
|
|
|
+ $posts = $this->posts->all();
|
|
|
+// $posts = Post::latest()
|
|
|
+// ->filter($request->only(['month', 'year']))
|
|
|
+// ->get();
|
|
|
|
|
|
return view('posts.index', compact('posts'));
|
|
|
}
|