This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Murzik
Murzik

Hi all

I've 2 models "Photo" and "Tag" with relationship many-to-many, via pivot table. Photo model contains some description fields and picture file attached.

Now I can create Photo by one record and select existing Tags, and I can select existing Photos when I create/edit Tag. But this is not convinient when you have to upload a lot of photos.

Is there a way to upload many picture files on the Tag edit page so that the system created related new Photo records with uploaded picture as photo and some default descriptions? Could you help me with this please?

Models:

class Photo extends Model
{
    public $table = 'murzik_gallery_photo';
        $belongsToMany=[
            'tags'=>[
                'murzik\gallery\models\Tag',
                'table'=>'murzik_gallery_photo_tag',
                'order'=>'title']
    ];    
     public $attachOne=['pic'=>'System\Models\File'];
 }

class Tag extends Model
{
   public $table = 'murzik_gallery_tag';    
   public $belongsToMany=[
        'photos'=>[
            'murzik\gallery\models\Photo',
            'table'=>'murzik_gallery_photo_tag',
            'order'=>'title']
    ];
}

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.