DEV Community

Cover image for Tinker Create & Update Record Laravel
Asep Septiadi
Asep Septiadi

Posted on

Tinker Create & Update Record Laravel

Create Record

> App\Models\Barang::create([
. 'kode_barang' => 'PRD-G3921',
. 'nama_barang' => 'Pocky Chocolate',
. 'kategori_barang' => 'Snack',
. 'harga' => 3000,
. 'stock' => 20,
. 'sisa' => 18,
. ]);
= App\Models\Barang {#6249
    kode_barang: "PRD-G3921",
    nama_barang: "Pocky Chocolate",
    kategori_barang: "Snack",
    harga: 3000,
    stock: 20,
    sisa: 18,
    updated_at: "2023-10-31 13:15:09",
    created_at: "2023-10-31 13:15:09",
    id: 1,
  }
Enter fullscreen mode Exit fullscreen mode

Update Record

> App\Models\Barang::where('id', 1)->update([
. 'nama_barang' => 'Pocky Chocolate Mix 5 Stick'
. ]);
= 1
Enter fullscreen mode Exit fullscreen mode

Result Update by Tinker

Image description

Top comments (2)

Collapse
 
yth_maulana profile image
Maulana

Mantap asep

Collapse
 
muhamadsyafii profile image
Muhamad Syafii

ngerii