// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.

package factory

import (
	"context"
	"testing"
	"time"

	"github.com/Gleipnir-Technology/bob"
	models "github.com/Gleipnir-Technology/nidus-sync/db/models"
	"github.com/aarondl/opt/null"
	"github.com/aarondl/opt/omit"
	"github.com/aarondl/opt/omitnull"
	"github.com/google/uuid"
	"github.com/jaswdr/faker/v2"
)

type PublicreportImageMod interface {
	Apply(context.Context, *PublicreportImageTemplate)
}

type PublicreportImageModFunc func(context.Context, *PublicreportImageTemplate)

func (f PublicreportImageModFunc) Apply(ctx context.Context, n *PublicreportImageTemplate) {
	f(ctx, n)
}

type PublicreportImageModSlice []PublicreportImageMod

func (mods PublicreportImageModSlice) Apply(ctx context.Context, n *PublicreportImageTemplate) {
	for _, f := range mods {
		f.Apply(ctx, n)
	}
}

// PublicreportImageTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type PublicreportImageTemplate struct {
	ID               func() int32
	ContentType      func() string
	Created          func() time.Time
	Location         func() null.Val[string]
	ResolutionX      func() int32
	ResolutionY      func() int32
	StorageUUID      func() uuid.UUID
	StorageSize      func() int64
	UploadedFilename func() string

	r publicreportImageR
	f *Factory

	alreadyPersisted bool
}

type publicreportImageR struct {
	ImageExifs []*publicreportImageRImageExifsR
	Nuisances  []*publicreportImageRNuisancesR
	Pools      []*publicreportImageRPoolsR
	Quicks     []*publicreportImageRQuicksR
}

type publicreportImageRImageExifsR struct {
	number int
	o      *PublicreportImageExifTemplate
}
type publicreportImageRNuisancesR struct {
	number int
	o      *PublicreportNuisanceTemplate
}
type publicreportImageRPoolsR struct {
	number int
	o      *PublicreportPoolTemplate
}
type publicreportImageRQuicksR struct {
	number int
	o      *PublicreportQuickTemplate
}

// Apply mods to the PublicreportImageTemplate
func (o *PublicreportImageTemplate) Apply(ctx context.Context, mods ...PublicreportImageMod) {
	for _, mod := range mods {
		mod.Apply(ctx, o)
	}
}

// setModelRels creates and sets the relationships on *models.PublicreportImage
// according to the relationships in the template. Nothing is inserted into the db
func (t PublicreportImageTemplate) setModelRels(o *models.PublicreportImage) {
	if t.r.ImageExifs != nil {
		rel := models.PublicreportImageExifSlice{}
		for _, r := range t.r.ImageExifs {
			related := r.o.BuildMany(r.number)
			for _, rel := range related {
				rel.ImageID = o.ID // h2
				rel.R.Image = o
			}
			rel = append(rel, related...)
		}
		o.R.ImageExifs = rel
	}

	if t.r.Nuisances != nil {
		rel := models.PublicreportNuisanceSlice{}
		for _, r := range t.r.Nuisances {
			related := r.o.BuildMany(r.number)
			for _, rel := range related {
				rel.R.Images = append(rel.R.Images, o)
			}
			rel = append(rel, related...)
		}
		o.R.Nuisances = rel
	}

	if t.r.Pools != nil {
		rel := models.PublicreportPoolSlice{}
		for _, r := range t.r.Pools {
			related := r.o.BuildMany(r.number)
			for _, rel := range related {
				rel.R.Images = append(rel.R.Images, o)
			}
			rel = append(rel, related...)
		}
		o.R.Pools = rel
	}

	if t.r.Quicks != nil {
		rel := models.PublicreportQuickSlice{}
		for _, r := range t.r.Quicks {
			related := r.o.BuildMany(r.number)
			for _, rel := range related {
				rel.R.Images = append(rel.R.Images, o)
			}
			rel = append(rel, related...)
		}
		o.R.Quicks = rel
	}
}

// BuildSetter returns an *models.PublicreportImageSetter
// this does nothing with the relationship templates
func (o PublicreportImageTemplate) BuildSetter() *models.PublicreportImageSetter {
	m := &models.PublicreportImageSetter{}

	if o.ID != nil {
		val := o.ID()
		m.ID = omit.From(val)
	}
	if o.ContentType != nil {
		val := o.ContentType()
		m.ContentType = omit.From(val)
	}
	if o.Created != nil {
		val := o.Created()
		m.Created = omit.From(val)
	}
	if o.Location != nil {
		val := o.Location()
		m.Location = omitnull.FromNull(val)
	}
	if o.ResolutionX != nil {
		val := o.ResolutionX()
		m.ResolutionX = omit.From(val)
	}
	if o.ResolutionY != nil {
		val := o.ResolutionY()
		m.ResolutionY = omit.From(val)
	}
	if o.StorageUUID != nil {
		val := o.StorageUUID()
		m.StorageUUID = omit.From(val)
	}
	if o.StorageSize != nil {
		val := o.StorageSize()
		m.StorageSize = omit.From(val)
	}
	if o.UploadedFilename != nil {
		val := o.UploadedFilename()
		m.UploadedFilename = omit.From(val)
	}

	return m
}

// BuildManySetter returns an []*models.PublicreportImageSetter
// this does nothing with the relationship templates
func (o PublicreportImageTemplate) BuildManySetter(number int) []*models.PublicreportImageSetter {
	m := make([]*models.PublicreportImageSetter, number)

	for i := range m {
		m[i] = o.BuildSetter()
	}

	return m
}

// Build returns an *models.PublicreportImage
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use PublicreportImageTemplate.Create
func (o PublicreportImageTemplate) Build() *models.PublicreportImage {
	m := &models.PublicreportImage{}

	if o.ID != nil {
		m.ID = o.ID()
	}
	if o.ContentType != nil {
		m.ContentType = o.ContentType()
	}
	if o.Created != nil {
		m.Created = o.Created()
	}
	if o.Location != nil {
		m.Location = o.Location()
	}
	if o.ResolutionX != nil {
		m.ResolutionX = o.ResolutionX()
	}
	if o.ResolutionY != nil {
		m.ResolutionY = o.ResolutionY()
	}
	if o.StorageUUID != nil {
		m.StorageUUID = o.StorageUUID()
	}
	if o.StorageSize != nil {
		m.StorageSize = o.StorageSize()
	}
	if o.UploadedFilename != nil {
		m.UploadedFilename = o.UploadedFilename()
	}

	o.setModelRels(m)

	return m
}

// BuildMany returns an models.PublicreportImageSlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use PublicreportImageTemplate.CreateMany
func (o PublicreportImageTemplate) BuildMany(number int) models.PublicreportImageSlice {
	m := make(models.PublicreportImageSlice, number)

	for i := range m {
		m[i] = o.Build()
	}

	return m
}

func ensureCreatablePublicreportImage(m *models.PublicreportImageSetter) {
	if !(m.ContentType.IsValue()) {
		val := random_string(nil)
		m.ContentType = omit.From(val)
	}
	if !(m.Created.IsValue()) {
		val := random_time_Time(nil)
		m.Created = omit.From(val)
	}
	if !(m.ResolutionX.IsValue()) {
		val := random_int32(nil)
		m.ResolutionX = omit.From(val)
	}
	if !(m.ResolutionY.IsValue()) {
		val := random_int32(nil)
		m.ResolutionY = omit.From(val)
	}
	if !(m.StorageUUID.IsValue()) {
		val := random_uuid_UUID(nil)
		m.StorageUUID = omit.From(val)
	}
	if !(m.StorageSize.IsValue()) {
		val := random_int64(nil)
		m.StorageSize = omit.From(val)
	}
	if !(m.UploadedFilename.IsValue()) {
		val := random_string(nil)
		m.UploadedFilename = omit.From(val)
	}
}

// insertOptRels creates and inserts any optional the relationships on *models.PublicreportImage
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *PublicreportImageTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportImage) error {
	var err error

	isImageExifsDone, _ := publicreportImageRelImageExifsCtx.Value(ctx)
	if !isImageExifsDone && o.r.ImageExifs != nil {
		ctx = publicreportImageRelImageExifsCtx.WithValue(ctx, true)
		for _, r := range o.r.ImageExifs {
			if r.o.alreadyPersisted {
				m.R.ImageExifs = append(m.R.ImageExifs, r.o.Build())
			} else {
				rel0, err := r.o.CreateMany(ctx, exec, r.number)
				if err != nil {
					return err
				}

				err = m.AttachImageExifs(ctx, exec, rel0...)
				if err != nil {
					return err
				}
			}
		}
	}

	isNuisancesDone, _ := publicreportImageRelNuisancesCtx.Value(ctx)
	if !isNuisancesDone && o.r.Nuisances != nil {
		ctx = publicreportImageRelNuisancesCtx.WithValue(ctx, true)
		for _, r := range o.r.Nuisances {
			if r.o.alreadyPersisted {
				m.R.Nuisances = append(m.R.Nuisances, r.o.Build())
			} else {
				rel1, err := r.o.CreateMany(ctx, exec, r.number)
				if err != nil {
					return err
				}

				err = m.AttachNuisances(ctx, exec, rel1...)
				if err != nil {
					return err
				}
			}
		}
	}

	isPoolsDone, _ := publicreportImageRelPoolsCtx.Value(ctx)
	if !isPoolsDone && o.r.Pools != nil {
		ctx = publicreportImageRelPoolsCtx.WithValue(ctx, true)
		for _, r := range o.r.Pools {
			if r.o.alreadyPersisted {
				m.R.Pools = append(m.R.Pools, r.o.Build())
			} else {
				rel2, err := r.o.CreateMany(ctx, exec, r.number)
				if err != nil {
					return err
				}

				err = m.AttachPools(ctx, exec, rel2...)
				if err != nil {
					return err
				}
			}
		}
	}

	isQuicksDone, _ := publicreportImageRelQuicksCtx.Value(ctx)
	if !isQuicksDone && o.r.Quicks != nil {
		ctx = publicreportImageRelQuicksCtx.WithValue(ctx, true)
		for _, r := range o.r.Quicks {
			if r.o.alreadyPersisted {
				m.R.Quicks = append(m.R.Quicks, r.o.Build())
			} else {
				rel3, err := r.o.CreateMany(ctx, exec, r.number)
				if err != nil {
					return err
				}

				err = m.AttachQuicks(ctx, exec, rel3...)
				if err != nil {
					return err
				}
			}
		}
	}

	return err
}

// Create builds a publicreportImage and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *PublicreportImageTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportImage, error) {
	var err error
	opt := o.BuildSetter()
	ensureCreatablePublicreportImage(opt)

	m, err := models.PublicreportImages.Insert(opt).One(ctx, exec)
	if err != nil {
		return nil, err
	}

	if err := o.insertOptRels(ctx, exec, m); err != nil {
		return nil, err
	}
	return m, err
}

// MustCreate builds a publicreportImage and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *PublicreportImageTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportImage {
	m, err := o.Create(ctx, exec)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateOrFail builds a publicreportImage and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
func (o *PublicreportImageTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportImage {
	tb.Helper()
	m, err := o.Create(ctx, exec)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// CreateMany builds multiple publicreportImages and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o PublicreportImageTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportImageSlice, error) {
	var err error
	m := make(models.PublicreportImageSlice, number)

	for i := range m {
		m[i], err = o.Create(ctx, exec)
		if err != nil {
			return nil, err
		}
	}

	return m, nil
}

// MustCreateMany builds multiple publicreportImages and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o PublicreportImageTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportImageSlice {
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateManyOrFail builds multiple publicreportImages and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
func (o PublicreportImageTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportImageSlice {
	tb.Helper()
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// PublicreportImage has methods that act as mods for the PublicreportImageTemplate
var PublicreportImageMods publicreportImageMods

type publicreportImageMods struct{}

func (m publicreportImageMods) RandomizeAllColumns(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModSlice{
		PublicreportImageMods.RandomID(f),
		PublicreportImageMods.RandomContentType(f),
		PublicreportImageMods.RandomCreated(f),
		PublicreportImageMods.RandomLocation(f),
		PublicreportImageMods.RandomResolutionX(f),
		PublicreportImageMods.RandomResolutionY(f),
		PublicreportImageMods.RandomStorageUUID(f),
		PublicreportImageMods.RandomStorageSize(f),
		PublicreportImageMods.RandomUploadedFilename(f),
	}
}

// Set the model columns to this value
func (m publicreportImageMods) ID(val int32) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) IDFunc(f func() int32) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ID = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetID() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ID = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomID(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ID = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) ContentType(val string) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ContentType = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) ContentTypeFunc(f func() string) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ContentType = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetContentType() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ContentType = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomContentType(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ContentType = func() string {
			return random_string(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) Created(val time.Time) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Created = func() time.Time { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) CreatedFunc(f func() time.Time) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Created = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetCreated() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Created = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomCreated(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Created = func() time.Time {
			return random_time_Time(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) Location(val null.Val[string]) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Location = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) LocationFunc(f func() null.Val[string]) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Location = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetLocation() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Location = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
func (m publicreportImageMods) RandomLocation(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Location = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f)
			return null.From(val)
		}
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
func (m publicreportImageMods) RandomLocationNotNull(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.Location = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) ResolutionX(val int32) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionX = func() int32 { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) ResolutionXFunc(f func() int32) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionX = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetResolutionX() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionX = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomResolutionX(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionX = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) ResolutionY(val int32) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionY = func() int32 { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) ResolutionYFunc(f func() int32) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionY = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetResolutionY() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionY = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomResolutionY(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.ResolutionY = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) StorageUUID(val uuid.UUID) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageUUID = func() uuid.UUID { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) StorageUUIDFunc(f func() uuid.UUID) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageUUID = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetStorageUUID() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageUUID = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomStorageUUID(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageUUID = func() uuid.UUID {
			return random_uuid_UUID(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) StorageSize(val int64) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageSize = func() int64 { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) StorageSizeFunc(f func() int64) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageSize = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetStorageSize() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageSize = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomStorageSize(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.StorageSize = func() int64 {
			return random_int64(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportImageMods) UploadedFilename(val string) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.UploadedFilename = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportImageMods) UploadedFilenameFunc(f func() string) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.UploadedFilename = f
	})
}

// Clear any values for the column
func (m publicreportImageMods) UnsetUploadedFilename() PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.UploadedFilename = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportImageMods) RandomUploadedFilename(f *faker.Faker) PublicreportImageMod {
	return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
		o.UploadedFilename = func() string {
			return random_string(f)
		}
	})
}

func (m publicreportImageMods) WithParentsCascading() PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		if isDone, _ := publicreportImageWithParentsCascadingCtx.Value(ctx); isDone {
			return
		}
		ctx = publicreportImageWithParentsCascadingCtx.WithValue(ctx, true)
	})
}

func (m publicreportImageMods) WithImageExifs(number int, related *PublicreportImageExifTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.ImageExifs = []*publicreportImageRImageExifsR{{
			number: number,
			o:      related,
		}}
	})
}

func (m publicreportImageMods) WithNewImageExifs(number int, mods ...PublicreportImageExifMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportImageExifWithContext(ctx, mods...)
		m.WithImageExifs(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddImageExifs(number int, related *PublicreportImageExifTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.ImageExifs = append(o.r.ImageExifs, &publicreportImageRImageExifsR{
			number: number,
			o:      related,
		})
	})
}

func (m publicreportImageMods) AddNewImageExifs(number int, mods ...PublicreportImageExifMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportImageExifWithContext(ctx, mods...)
		m.AddImageExifs(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddExistingImageExifs(existingModels ...*models.PublicreportImageExif) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		for _, em := range existingModels {
			o.r.ImageExifs = append(o.r.ImageExifs, &publicreportImageRImageExifsR{
				o: o.f.FromExistingPublicreportImageExif(em),
			})
		}
	})
}

func (m publicreportImageMods) WithoutImageExifs() PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.ImageExifs = nil
	})
}

func (m publicreportImageMods) WithNuisances(number int, related *PublicreportNuisanceTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Nuisances = []*publicreportImageRNuisancesR{{
			number: number,
			o:      related,
		}}
	})
}

func (m publicreportImageMods) WithNewNuisances(number int, mods ...PublicreportNuisanceMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportNuisanceWithContext(ctx, mods...)
		m.WithNuisances(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddNuisances(number int, related *PublicreportNuisanceTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Nuisances = append(o.r.Nuisances, &publicreportImageRNuisancesR{
			number: number,
			o:      related,
		})
	})
}

func (m publicreportImageMods) AddNewNuisances(number int, mods ...PublicreportNuisanceMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportNuisanceWithContext(ctx, mods...)
		m.AddNuisances(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddExistingNuisances(existingModels ...*models.PublicreportNuisance) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		for _, em := range existingModels {
			o.r.Nuisances = append(o.r.Nuisances, &publicreportImageRNuisancesR{
				o: o.f.FromExistingPublicreportNuisance(em),
			})
		}
	})
}

func (m publicreportImageMods) WithoutNuisances() PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Nuisances = nil
	})
}

func (m publicreportImageMods) WithPools(number int, related *PublicreportPoolTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Pools = []*publicreportImageRPoolsR{{
			number: number,
			o:      related,
		}}
	})
}

func (m publicreportImageMods) WithNewPools(number int, mods ...PublicreportPoolMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportPoolWithContext(ctx, mods...)
		m.WithPools(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddPools(number int, related *PublicreportPoolTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Pools = append(o.r.Pools, &publicreportImageRPoolsR{
			number: number,
			o:      related,
		})
	})
}

func (m publicreportImageMods) AddNewPools(number int, mods ...PublicreportPoolMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportPoolWithContext(ctx, mods...)
		m.AddPools(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddExistingPools(existingModels ...*models.PublicreportPool) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		for _, em := range existingModels {
			o.r.Pools = append(o.r.Pools, &publicreportImageRPoolsR{
				o: o.f.FromExistingPublicreportPool(em),
			})
		}
	})
}

func (m publicreportImageMods) WithoutPools() PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Pools = nil
	})
}

func (m publicreportImageMods) WithQuicks(number int, related *PublicreportQuickTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Quicks = []*publicreportImageRQuicksR{{
			number: number,
			o:      related,
		}}
	})
}

func (m publicreportImageMods) WithNewQuicks(number int, mods ...PublicreportQuickMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportQuickWithContext(ctx, mods...)
		m.WithQuicks(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddQuicks(number int, related *PublicreportQuickTemplate) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Quicks = append(o.r.Quicks, &publicreportImageRQuicksR{
			number: number,
			o:      related,
		})
	})
}

func (m publicreportImageMods) AddNewQuicks(number int, mods ...PublicreportQuickMod) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		related := o.f.NewPublicreportQuickWithContext(ctx, mods...)
		m.AddQuicks(number, related).Apply(ctx, o)
	})
}

func (m publicreportImageMods) AddExistingQuicks(existingModels ...*models.PublicreportQuick) PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		for _, em := range existingModels {
			o.r.Quicks = append(o.r.Quicks, &publicreportImageRQuicksR{
				o: o.f.FromExistingPublicreportQuick(em),
			})
		}
	})
}

func (m publicreportImageMods) WithoutQuicks() PublicreportImageMod {
	return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
		o.r.Quicks = nil
	})
}
