I am trying to return a JSON response which consists of an array of accounts where each account has one currency(name, rate).
currency.php model:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class currency extends Model {
protected $fillable = array('name', 'rate');
public function group(){
return $this->belongsTo('account');
}
}
account.php model:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class account extends Model {
public function currency(){
return $this->hasOne('currency');
}
}
and my AccountController:
public function index()
{
$accounts = Account::with('currency')->get();
return $accounts;
}
No matter what I tried to change i always get this error: Class 'Currency' not found What am I doing wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire