Im new to L5 and here, stackoverflow. I'm making a Blog service based on Repository pattern. Now I've made some Service class(like ImageService, PostService, CommentService...) and Repositories as data access object.
From now, I will make views. First, "Top page" I would like to. Need to inject 2 Service class. "ImageService(allUsersImages)", "PostService(allUsersPosts)".
I am stopping here....bothering what the best way. please let me know if my thought is good, or is there any way?
1.Creating Controller
class IndexController extends Controller
{
public function top(ImageRepository $image, PostRepository $post)
{
$images= $image->allUsersImages();
$posts= $post->allUsersPosts();
return view('/index')
->with('images', $images)
->with('posts', $posts);
}
public function mypage(ImageRepository $image,
PostRepository $post, $id)
{
$images= $image->allUsersImagesById($id);
$posts= $post->allUsersPosts($id);
return view('/index')
->with('images', $images)
->with('posts', $posts);
}
.
.
.
.
prepare methods for each page
}
2. Creating routing
Route::get('/top', 'IndexController@top');
Route::get('/mypage', 'IndexController@mypage');
.
.
.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jNmffy
via IFTTT
Aucun commentaire:
Enregistrer un commentaire