This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
just one more quick question - how can I display this on the front end.
I've created my albums/:slug page and then created {{record.album_id }} but this doesn't display anything.
I know in blade you would need to call the method but not sure how this is done in twig
Glad you got it working. I told you to remove the relation from the model for the form, but I forgot to mention that you will need to define the relation in columns.yaml of the model for it to show in the index table.
Sorry, I haven't started working on the frontend yet. :/ Couldn't tell you. but if you can access the model, perhaps try using a standard eloquent relation and calling that. I.E.
public function album() {
return $this->belongsTo('Company/Plugin/Album');
}
and then just
$record->album;
Last updated
you have to go to model class file for example in my project it is movie.php there you have to define relation in this way:
<?php namespace Shajid\Movies\Models;
use Model;
/**
-
Model */ class Movie extends Model { use \October\Rain\Database\Traits\Validation;
/*
- Validation */ public $rules = [ ];
/*
- Disable timestamps by default.
- Remove this line if timestamps are defined in the database table. */ public $timestamps = false;
/**
- @var string The database table used by the model. */ public $table = 'shajidmovies';
/ Relation /
public $belongsToMany = [
'genres' => [
'Shajid\Movies\Models\Genre',
'table' => 'shajid_movies_movies_genres',
'order' => 'genre_title'
]
];
public $attachOne = [
'poster' => 'System\Models\File'
];
public $attachMany = [
'movie_gallery' => 'System\Models\File'
];
} may be your problem get solved.