1) У меня есть модель Property
public function images()
{
return $this->hasMany(PropertyImages::class);
}
2) Моя таблица для модели PropertyImages выглядит следующим образом:
Schema::create('property_images', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title')->nullable();
$table->string('src');
$table->string('mime_type')->nullable();
$table->string('alt')->nullable();
$table->text('description')->nullable();
$table->integer('property_id');
$table->timestamps();
});
3) Когда у меня есть код:
$properties = Property::all();
dd($properties->images());
Кажется, ничего не работает. Я хочу, чтобы у каждого свойства было множество изображений, и мне интересно, почему оно не распознает данные. Я получаю следующую ошибку: Метод BadMethodCallException Illuminate \ Database \ Eloquent \ Collection :: images не существует.