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