alisaracoglu
alisaracoglu

my system;

I use my octobercms website as a service for my mobile app. Mobile users take multiple photos and save them on their own account. For this, I associate each user with their photos with "file attachments relationship" in the my user model.

public $attachMany = [
    'photos' => 'System\Models\File'
];

when they(users) want to update one of the photos;

I loop all the photos of that user. If I understand that the picture is the correct one using the if condition, I am changing it.

foreach ($model->photos as $photo) {
    if ( is $photo correct photo ) {
       // update process
    }
}

my question

To avoid looping all images with foreach;

Is there a method like adding a key during saving process and then taking the photo with that key? Or what is the best practice of this process.

Last updated

alisaracoglu
Plefusbacce
Plefusbacce

This is good service with Multiple photos on account and It is very helpful and useful.

1-3 of 3