Support the ongoing development of Laravel.io →
Requests Input Eloquent
Last updated 2 years ago.
0
Solution

I think he/she meant to create a repository class.

Your controller would look something like

<?php

use Vanpet\Repositories\AgendaRepositoryInterface;

class AgendaController extends Controller {

    protected $agenda;

    public function __construct(AgendaRepositoryInterface $agenda)
    {
        $this->agenda = $agenda;
    }

    public function show($year, $month, $day)
    {
        if($this->agenda->findByDate($year, $month, $day, Input::all()) {
            return View::make('agenda.show', $agenda);
        } else {
            return View::make('error.page');
        }
    }

and then in your repository you would do all the stuff necessary to return the correct angenda(s)

Above might be a lot of info for a beginner but let me know if it makes sense.

Last updated 2 years ago.
0

Ok I will create a repository.

I fear I may have to come back for more help with the findByDate method, but that will be for later!

Thanks!

Last updated 2 years ago.
0

vanpet said:

Ok I will create a repository.

I fear I may have to come back for more help with the findByDate method, but that will be for later!

Thanks!

findByDate is your own method in the repository, you can name it whatever you like

Last updated 2 years ago.
0

Yeah, but it's the inside of that method that will be hard to code, I guess ;-)

Last updated 2 years ago.
0

vanpet said:

Yeah, but it's the inside of that method that will be hard to code, I guess ;-)

try to create an AgendaRepository, an AuthorRepository, a TagRepository and etc and then use your TagRepository in your AgendaRepository

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

vanpet vanpet Joined 10 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.