I'm working on laravel's project flyer and I'm continually getting this error from artisan tinker.
$flyer->photos()->create(['photo' => 'foo.jpg']);
BadMethodCallException with message 'Call to undefined method Illuminate \Database\Query\Builder::photos()'
Here is my Flyer.php file:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Flyer extends Model
{
public function photos()
{
return $this->hasMany('App\Photo');
}
}
and here is my Photo.php file:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Photo extends Model
{
protected $table = 'flyer_photos';
protected $fillable = ['photo'];
public function flyer()
{
return $this->belongsTo('App\Flyer');
}
}
looks like the method photos() doesn't get recognised or something
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire