Pregunta

This is driving me nuts. I have 2 tables;

  1. explanations and
  2. transactions.

In the models folder I have transaction.php and explanation.php.

transactions.php:

<?php

class Transaction extends Eloquent {

    public function explanation()
    {
        return $this->hasOne('Explanation');
    }

}

explanation.php

<?php

class Explanation extends Eloquent {



}

I'm simply calling

Transaction::find(18)->explanation()->first();

The error that I'm receiving is

Method [hasone] is not defined on the Query class

Can anyone see where I'm going wrong?

¿Fue útil?

Solución

Just figured this out, was reading the wrong documentation..

Laravel 4.x

$this->hasOne();

Laravel < 4.x

$this->has_one();
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top