PageSourceSearch

https://firestore-eloquent.netlify.app/assets/js/38fa9132.65ca92d8.js

js firestore-eloquent.netlify.app collected 2026-10-03 10:45:12 UTC 4,447 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkfirestore_eloquent=self.webpackChunkfirestore_eloquent||[]).push([[6562],{1387:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>a,default:()=>l,frontMatter:()=>r,metadata:()=>s,toc:()=>u});var i=n(5893),d=n(1151);const r={sidebar_position:3},a="Updating data",s={id:"guide/eloquent/updating-data",title:"Updating data",description:"Updating Documents in Firestore Eloquent Library",source:"@site/docs/guide/eloquent/updating-data.mdx",sourceDirName:"guide/eloquent",slug:"/guide/eloquent/updating-data",permalink:"/docs/guide/eloquent/updating-data",draft:!1,unlisted:!1,editUrl:"https://github.com/FreddyWhest/firestore-eloquent-docs/tree/main/docs/guide/eloquent/updating-data.mdx",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"Retrieving data",permalink:"/docs/guide/eloquent/retrieving-data"},next:{title:"Create Document",permalink:"/docs/guide/eloquent/create"}},o={},u=[{value:"Updating Documents in Firestore Eloquent Library",id:"updating-documents-in-firestore-eloquent-library",level:2},{value:"Partial Update with <code>update()</code>",id:"partial-update-with-update",level:2},{value:"Basic Update",id:"basic-update",level:3},{value:"Update Multiple Fields",id:"update-multiple-fields",level:3}];function c(e){const t={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,d.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.h1,{id:"updating-data",children:"Updating data"}),"\n",(0,i.jsx)(t.h2,{id:"updating-documents-in-firestore-eloquent-library",children:"Updating Documents in Firestore Eloquent Library"}),"\n",(0,i.jsx)(t.p,{children:"Updating documents in Firestore is a common operation, and the Firestore Eloquent Library in Laravel provides convenient methods to perform updates. Let's explore how to update documents using the library's features."}),"\n",(0,i.jsxs)(t.h2,{id:"partial-update-with-update",children:["Partial Update with ",(0,i.jsx)(t.code,{children:"update()"})]}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"update()"})," method allows you to update a single document in a Firestore collection. You can use this method to update fields of a document that match certain conditions."]}),"\n",(0,i.jsx)(t.h3,{id:"basic-update",children:"Basic Update"}),"\n",(0,i.jsxs)(t.p,{children:["Let's update the ",(0,i.jsx)(t.code,{children:"age"})," field of the document with the ",(0,i.jsx)(t.code,{children:"id"})," ",(0,i.jsx)(t.code,{children:"1234"})," in the ",(0,i.jsx)(t.code,{children:"users"})," collection."]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-php",children:"// Update a user with the specified ID\r\n$userId = '1234';\r\n$user = User::find($userId);\r\n$updatedUser = $user->update([\r\n    'age' => 30\r\n]);\r\n\n"})}),"\n",(0,i.jsx)(t.h3,{id:"update-multiple-fields",children:"Update Multiple Fields"}),"\n",(0,i.jsxs)(t.p,{children:["You can also update multiple fields of a document. Let's update the ",(0,i.jsx)(t.code,{children:"status"})," and ",(0,i.jsx)(t.code,{children:"age"})," fields of the document with the ",(0,i.jsx)(t.code,{children:"id"})," ",(0,i.jsx)(t.code,{children:"1234"})," in the ",(0,i.jsx)(t.code,{children:"users"})," collection."]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-php",children:"// Update a user with the specified ID\r\n// Update a user with the specified ID\r\n$user = User::where(['user_id', '=', $userId])->first();\r\n$updatedUser = $user->update([\r\n    'age' => 30, \r\n    'status' => 'inactive'\r\n]);\r\n\n"})}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-php",children:"// Update a user with the specified ID\r\n$user = User::where(['user_id', '=', $userId])->firstOrFail();\r\n$updatedUser = $user->update([\r\n    'age' => 30, \r\n    'status' => 'inactive'\r\n]);\r\n\n"})})]})}function l(e={}){const{wrapper:t}={...(0,d.a)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},1151:(e,t,n)=>{n.d(t,{Z:()=>s,a:()=>a});var i=n(7294);const d={},r=i.createContext(d);function a(e){const t=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function s(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:a(e.components),i.createElement(r.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.