main
1import DS from 'ember-data';
2
3export default DS.Model.extend({
4 name: DS.attr('string'),
5 description: DS.attr('string'),
6 category: DS.belongsTo('category'),
7 author: DS.belongsTo('user'),
8 photos: DS.hasMany('photo'),
9 createdAt: DS.attr('date'),
10 updatedAt: DS.attr('date'),
11
12 primaryPhoto: function(){
13 return this.get('selectedPhoto') || this.get('photos.firstObject');
14 }.property('selectedPhoto', 'photos.firstObject'),
15 choosePhoto: function(photo) {
16 this.set('selectedPhoto', photo);
17 },
18});