laracasts/Presenter

Some help with namespaced entities

Closed this issue · 1 comments

I have

composer.json
"autoload": {
        "psr-4": {
            "BMTracking\\": "app/BMTracking"
        }
    }
/app/BMTracking/Entities/Question.php
<?php namespace BMTracking\Entities;

use Laracasts\Presenter\PresentableTrait;

class Question extends \Eloquent {

    use PresentableTrait;

   /**
     * @var string
     */
    protected $presenter = 'BMTracking\Preseters\QuestionPresenter';
/app/BMTracking/Presenters/QuestionPresenter.php
<?php namespace BMTracking\Presenters;

use Laracasts\Presenter\Presenter;

class QuestionPresenter extends Presenter {

    public function company()
    {
        return $this->company->name;
    }

    public function group()
    {
        return $this->groups{$this->entity->for};
    }

    public function frequency()
    {
        return $this->frequencies{$this->entity->frequency};
    }

    public function type()
    {
        return $this->types{$this->entity->type};
    }

}

And I receive

Please set the $presenter property to your presenter path. (View: /app/views/questions/index.blade.php)

The view is a simple foreach

@foreach ($questions as $question)
            <tr>
                <td>{{ $question->text }}</td>
                <td>{{ $question->present()->company }}</td>
                <td>{{ $question->present()->group }}</td>
                <td>{{ $question->present()->for_id }}</td>
                <td>{{ $question->sort }}</td>
                <td>{{ $question->active }}</td>
                <td>{{ $question->present()->frequency }}</td>
                <td>{{ $question->present()->type }}</td>
            </tr>
        @endforeach

Whant am I doing wrong? How can I track if the presenter class is loaded?

I had a typo in the $presenter string :|