Reputation: 3370
I have two entities: users, announcements
Eaach user can publish the announcements.
I creted controller AnnouncemetController
, where there is method class: my()
, that returns notes for current user.
Also I have controller ProfileController
that represent current profile user, where I need to show all announcements of user.
For this I tried to reuse controller AnnouncemetController
inside ProfileController
and call public method my()
.
use App\Http\Controllers\AnnouncementController;
class ProfileController extends Controller
{
$my = new AnnouncementController();
$my->my();
}
Is it well to use such?
Upvotes: 0
Views: 197
Reputation: 9579
A Laravel controller maps a uri to an action. In your example, you are using a controller to access data, so this is not the "right thing to do".
Instead use model methods to access the data.
Upvotes: 1