// 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"
	enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
	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/jaswdr/faker/v2"
)

type PublicreportQuickMod interface {
	Apply(context.Context, *PublicreportQuickTemplate)
}

type PublicreportQuickModFunc func(context.Context, *PublicreportQuickTemplate)

func (f PublicreportQuickModFunc) Apply(ctx context.Context, n *PublicreportQuickTemplate) {
	f(ctx, n)
}

type PublicreportQuickModSlice []PublicreportQuickMod

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

// PublicreportQuickTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type PublicreportQuickTemplate struct {
	ID             func() int32
	Created        func() time.Time
	Comments       func() string
	Location       func() null.Val[string]
	H3cell         func() null.Val[string]
	PublicID       func() string
	ReporterEmail  func() string
	ReporterPhone  func() string
	Address        func() string
	Status         func() enums.PublicreportReportstatustype
	OrganizationID func() null.Val[int32]

	r publicreportQuickR
	f *Factory

	alreadyPersisted bool
}

type publicreportQuickR struct {
	Organization *publicreportQuickROrganizationR
	Images       []*publicreportQuickRImagesR
}

type publicreportQuickROrganizationR struct {
	o *OrganizationTemplate
}
type publicreportQuickRImagesR struct {
	number int
	o      *PublicreportImageTemplate
}

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

// setModelRels creates and sets the relationships on *models.PublicreportQuick
// according to the relationships in the template. Nothing is inserted into the db
func (t PublicreportQuickTemplate) setModelRels(o *models.PublicreportQuick) {
	if t.r.Organization != nil {
		rel := t.r.Organization.o.Build()
		rel.R.Quicks = append(rel.R.Quicks, o)
		o.OrganizationID = null.From(rel.ID) // h2
		o.R.Organization = rel
	}

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

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

	if o.ID != nil {
		val := o.ID()
		m.ID = omit.From(val)
	}
	if o.Created != nil {
		val := o.Created()
		m.Created = omit.From(val)
	}
	if o.Comments != nil {
		val := o.Comments()
		m.Comments = omit.From(val)
	}
	if o.Location != nil {
		val := o.Location()
		m.Location = omitnull.FromNull(val)
	}
	if o.H3cell != nil {
		val := o.H3cell()
		m.H3cell = omitnull.FromNull(val)
	}
	if o.PublicID != nil {
		val := o.PublicID()
		m.PublicID = omit.From(val)
	}
	if o.ReporterEmail != nil {
		val := o.ReporterEmail()
		m.ReporterEmail = omit.From(val)
	}
	if o.ReporterPhone != nil {
		val := o.ReporterPhone()
		m.ReporterPhone = omit.From(val)
	}
	if o.Address != nil {
		val := o.Address()
		m.Address = omit.From(val)
	}
	if o.Status != nil {
		val := o.Status()
		m.Status = omit.From(val)
	}
	if o.OrganizationID != nil {
		val := o.OrganizationID()
		m.OrganizationID = omitnull.FromNull(val)
	}

	return m
}

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

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

	return m
}

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

	if o.ID != nil {
		m.ID = o.ID()
	}
	if o.Created != nil {
		m.Created = o.Created()
	}
	if o.Comments != nil {
		m.Comments = o.Comments()
	}
	if o.Location != nil {
		m.Location = o.Location()
	}
	if o.H3cell != nil {
		m.H3cell = o.H3cell()
	}
	if o.PublicID != nil {
		m.PublicID = o.PublicID()
	}
	if o.ReporterEmail != nil {
		m.ReporterEmail = o.ReporterEmail()
	}
	if o.ReporterPhone != nil {
		m.ReporterPhone = o.ReporterPhone()
	}
	if o.Address != nil {
		m.Address = o.Address()
	}
	if o.Status != nil {
		m.Status = o.Status()
	}
	if o.OrganizationID != nil {
		m.OrganizationID = o.OrganizationID()
	}

	o.setModelRels(m)

	return m
}

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

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

	return m
}

func ensureCreatablePublicreportQuick(m *models.PublicreportQuickSetter) {
	if !(m.Created.IsValue()) {
		val := random_time_Time(nil)
		m.Created = omit.From(val)
	}
	if !(m.Comments.IsValue()) {
		val := random_string(nil)
		m.Comments = omit.From(val)
	}
	if !(m.PublicID.IsValue()) {
		val := random_string(nil)
		m.PublicID = omit.From(val)
	}
	if !(m.ReporterEmail.IsValue()) {
		val := random_string(nil)
		m.ReporterEmail = omit.From(val)
	}
	if !(m.ReporterPhone.IsValue()) {
		val := random_string(nil)
		m.ReporterPhone = omit.From(val)
	}
	if !(m.Address.IsValue()) {
		val := random_string(nil)
		m.Address = omit.From(val)
	}
	if !(m.Status.IsValue()) {
		val := random_enums_PublicreportReportstatustype(nil)
		m.Status = omit.From(val)
	}
}

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

	isOrganizationDone, _ := publicreportQuickRelOrganizationCtx.Value(ctx)
	if !isOrganizationDone && o.r.Organization != nil {
		ctx = publicreportQuickRelOrganizationCtx.WithValue(ctx, true)
		if o.r.Organization.o.alreadyPersisted {
			m.R.Organization = o.r.Organization.o.Build()
		} else {
			var rel0 *models.Organization
			rel0, err = o.r.Organization.o.Create(ctx, exec)
			if err != nil {
				return err
			}
			err = m.AttachOrganization(ctx, exec, rel0)
			if err != nil {
				return err
			}
		}

	}

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

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

	return err
}

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

	m, err := models.PublicreportQuicks.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 publicreportQuick and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *PublicreportQuickTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportQuick {
	m, err := o.Create(ctx, exec)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateOrFail builds a publicreportQuick 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 *PublicreportQuickTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportQuick {
	tb.Helper()
	m, err := o.Create(ctx, exec)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

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

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

	return m, nil
}

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

// CreateManyOrFail builds multiple publicreportQuicks 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 PublicreportQuickTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportQuickSlice {
	tb.Helper()
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// PublicreportQuick has methods that act as mods for the PublicreportQuickTemplate
var PublicreportQuickMods publicreportQuickMods

type publicreportQuickMods struct{}

func (m publicreportQuickMods) RandomizeAllColumns(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModSlice{
		PublicreportQuickMods.RandomID(f),
		PublicreportQuickMods.RandomCreated(f),
		PublicreportQuickMods.RandomComments(f),
		PublicreportQuickMods.RandomLocation(f),
		PublicreportQuickMods.RandomH3cell(f),
		PublicreportQuickMods.RandomPublicID(f),
		PublicreportQuickMods.RandomReporterEmail(f),
		PublicreportQuickMods.RandomReporterPhone(f),
		PublicreportQuickMods.RandomAddress(f),
		PublicreportQuickMods.RandomStatus(f),
		PublicreportQuickMods.RandomOrganizationID(f),
	}
}

// Set the model columns to this value
func (m publicreportQuickMods) ID(val int32) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) IDFunc(f func() int32) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ID = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetID() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		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 publicreportQuickMods) RandomID(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ID = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) Created(val time.Time) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Created = func() time.Time { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) CreatedFunc(f func() time.Time) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Created = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetCreated() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		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 publicreportQuickMods) RandomCreated(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Created = func() time.Time {
			return random_time_Time(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) Comments(val string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Comments = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) CommentsFunc(f func() string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Comments = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetComments() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Comments = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportQuickMods) RandomComments(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Comments = func() string {
			return random_string(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) Location(val null.Val[string]) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Location = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) LocationFunc(f func() null.Val[string]) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Location = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetLocation() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		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 publicreportQuickMods) RandomLocation(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		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 publicreportQuickMods) RandomLocationNotNull(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		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 publicreportQuickMods) H3cell(val null.Val[string]) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.H3cell = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) H3cellFunc(f func() null.Val[string]) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.H3cell = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetH3cell() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.H3cell = 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 publicreportQuickMods) RandomH3cell(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.H3cell = 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 publicreportQuickMods) RandomH3cellNotNull(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.H3cell = 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 publicreportQuickMods) PublicID(val string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.PublicID = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) PublicIDFunc(f func() string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.PublicID = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetPublicID() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.PublicID = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportQuickMods) RandomPublicID(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.PublicID = func() string {
			return random_string(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) ReporterEmail(val string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterEmail = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) ReporterEmailFunc(f func() string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterEmail = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetReporterEmail() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterEmail = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportQuickMods) RandomReporterEmail(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterEmail = func() string {
			return random_string(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) ReporterPhone(val string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterPhone = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) ReporterPhoneFunc(f func() string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterPhone = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetReporterPhone() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterPhone = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportQuickMods) RandomReporterPhone(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.ReporterPhone = func() string {
			return random_string(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) Address(val string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Address = func() string { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) AddressFunc(f func() string) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Address = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetAddress() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Address = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportQuickMods) RandomAddress(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Address = func() string {
			return random_string(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) Status(val enums.PublicreportReportstatustype) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Status = func() enums.PublicreportReportstatustype { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) StatusFunc(f func() enums.PublicreportReportstatustype) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Status = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetStatus() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Status = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m publicreportQuickMods) RandomStatus(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.Status = func() enums.PublicreportReportstatustype {
			return random_enums_PublicreportReportstatustype(f)
		}
	})
}

// Set the model columns to this value
func (m publicreportQuickMods) OrganizationID(val null.Val[int32]) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.OrganizationID = func() null.Val[int32] { return val }
	})
}

// Set the Column from the function
func (m publicreportQuickMods) OrganizationIDFunc(f func() null.Val[int32]) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.OrganizationID = f
	})
}

// Clear any values for the column
func (m publicreportQuickMods) UnsetOrganizationID() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.OrganizationID = 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 publicreportQuickMods) RandomOrganizationID(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.OrganizationID = func() null.Val[int32] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_int32(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 publicreportQuickMods) RandomOrganizationIDNotNull(f *faker.Faker) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
		o.OrganizationID = func() null.Val[int32] {
			if f == nil {
				f = &defaultFaker
			}

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

func (m publicreportQuickMods) WithParentsCascading() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		if isDone, _ := publicreportQuickWithParentsCascadingCtx.Value(ctx); isDone {
			return
		}
		ctx = publicreportQuickWithParentsCascadingCtx.WithValue(ctx, true)
		{

			related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
			m.WithOrganization(related).Apply(ctx, o)
		}
	})
}

func (m publicreportQuickMods) WithOrganization(rel *OrganizationTemplate) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		o.r.Organization = &publicreportQuickROrganizationR{
			o: rel,
		}
	})
}

func (m publicreportQuickMods) WithNewOrganization(mods ...OrganizationMod) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		related := o.f.NewOrganizationWithContext(ctx, mods...)

		m.WithOrganization(related).Apply(ctx, o)
	})
}

func (m publicreportQuickMods) WithExistingOrganization(em *models.Organization) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		o.r.Organization = &publicreportQuickROrganizationR{
			o: o.f.FromExistingOrganization(em),
		}
	})
}

func (m publicreportQuickMods) WithoutOrganization() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		o.r.Organization = nil
	})
}

func (m publicreportQuickMods) WithImages(number int, related *PublicreportImageTemplate) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		o.r.Images = []*publicreportQuickRImagesR{{
			number: number,
			o:      related,
		}}
	})
}

func (m publicreportQuickMods) WithNewImages(number int, mods ...PublicreportImageMod) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		related := o.f.NewPublicreportImageWithContext(ctx, mods...)
		m.WithImages(number, related).Apply(ctx, o)
	})
}

func (m publicreportQuickMods) AddImages(number int, related *PublicreportImageTemplate) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		o.r.Images = append(o.r.Images, &publicreportQuickRImagesR{
			number: number,
			o:      related,
		})
	})
}

func (m publicreportQuickMods) AddNewImages(number int, mods ...PublicreportImageMod) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		related := o.f.NewPublicreportImageWithContext(ctx, mods...)
		m.AddImages(number, related).Apply(ctx, o)
	})
}

func (m publicreportQuickMods) AddExistingImages(existingModels ...*models.PublicreportImage) PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		for _, em := range existingModels {
			o.r.Images = append(o.r.Images, &publicreportQuickRImagesR{
				o: o.f.FromExistingPublicreportImage(em),
			})
		}
	})
}

func (m publicreportQuickMods) WithoutImages() PublicreportQuickMod {
	return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
		o.r.Images = nil
	})
}
