为什么我的控制器会给我带来这么多问题?

时间:2014-09-19 16:47:39

标签: php laravel view controller

我在视图页面上的注释中一直收到一个未定义的变量错误。

这是引起我所有问题的控制器:

 use Desk\Forms\MessageForm;
 use Desk\Records\MessageRecord;
 use Desk\Repositories\MessageRepository;

 class MessageController extends BaseController
 {

protected $messageForm;

public function __construct(MessageForm $messageForm, MessageRepository $messageRepository,
  MessageRecord $messageRecord)
{
    $this->messageForm = $messageForm;
    $this->messageRepository = $messageRepository;
    $this->messageRecord = $messageRecord;
}

/**
 * Display a listing of the resource.
 * GET /messages
 *
 * @return Response
 */
public function create()
{
    return View::make('comments.create');
}



public function display($comment)
{
    $message_id = $this->messageRepository->find($comment);
    return View::make('comments.show')->with('comment', $message_id);
}

/**
 * Store a newly created resource in storage.
 * POST /messaages
 *
 * @return Response
 */
public function store()
{
    $data = Input::all() ;
    $this->messageForm->validate($data);

    $messageRecord = new MessageRecord;
    $messageRecord->comment = $data['comment'];

    Return "Comment created";
}
}

这就是观点:

 <p>{{ $comment }}</p>

我无法理解可能导致这么多问题的原因。

0 个答案:

没有答案