Laravel Eloquent Model Events Lifecycle

·

1 min read

flowchart TD
    START((Model))
    START       --> UPDATE[Update]
    UPDATE      -->|Fill| SAVE{Save \n fa:fa-bolt saving}
    SAVE        -->|Check exists| EXISTS{Record Exists?}
    EXISTS      -->|Yes| UPDATING{Perform Update \n fa:fa-bolt updating}
    UPDATING    -->|Update Record| UPDATED[Update \n fa:fa-bolt updated]
    UPDATED     -->|Record Updated| SAVED[Finish Save \n fa:fa-bolt saved]
    SAVED       -->|Saved Successfully| END
    START       -->|__call:Builder| CREATE[Create]
    CREATE      -->|New Model Instance| SAVE
    EXISTS      -->|No| CREATING{Perform Insert \n fa:fa-bolt creating}
    CREATING    -->|Create Record| CREATED[Insert \n fa:fa-bolt created]
    CREATED     -->|Record Created| SAVED
    START       --> DELETE[Delete] 
    DELETE      --> |Check exists| DEL_EXISTS{Record Exists?}
    DEL_EXISTS  -->|Yes| DELETING_1{Delete \n fa:fa-bolt deleting}
    DELETING_1  --> DELETING_2[touchOwners]
    DELETING_2  -->|Delete Record| DELETING_3[performDeleteOnModel]
    DELETING_3  -->|Record Deleted| DELETED[Delete \n fa:fa-bolt deleted]
    DELETED     --> END
    DEL_EXISTS  -->|No| END
    END((End))
    linkStyle default stroke:#dfe857,stroke-width:4px,color:#FFF  
    classDef default fill:#FFF,stroke:#333,stroke-width:4px,color:black