github.com/goravel/framework@v1.13.9/database/orm/model.go (about)

     1  package orm
     2  
     3  import (
     4  	"errors"
     5  
     6  	"gorm.io/gorm"
     7  	"gorm.io/gorm/clause"
     8  
     9  	contractsorm "github.com/goravel/framework/contracts/database/orm"
    10  	"github.com/goravel/framework/support/carbon"
    11  )
    12  
    13  const Associations = clause.Associations
    14  
    15  var ErrRecordNotFound = errors.New("record not found")
    16  
    17  var Observers = make([]Observer, 0)
    18  
    19  type Observer struct {
    20  	Model    any
    21  	Observer contractsorm.Observer
    22  }
    23  
    24  type Model struct {
    25  	ID uint `gorm:"primaryKey"`
    26  	Timestamps
    27  }
    28  
    29  type SoftDeletes struct {
    30  	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"`
    31  }
    32  
    33  type Timestamps struct {
    34  	CreatedAt carbon.DateTime `gorm:"autoCreateTime;column:created_at"`
    35  	UpdatedAt carbon.DateTime `gorm:"autoUpdateTime;column:updated_at"`
    36  }