Clinton Green
Clinton Green

Reputation: 9977

Laravel - How to update field value in sqlite

On my laravel project, I created the following record in sqlite using php artisan tinker.

   App\Note {#642
     id: "1",
     card_id: "2",
     body: "Some note for the card",
     created_at: "2016-06-19 22:18:34",
     updated_at: "2016-06-19 22:18:34",
   }

How can I change the card_id field to 1 instead of 2?

Upvotes: 0

Views: 458

Answers (2)

Osama Sayed
Osama Sayed

Reputation: 2023

$note = App\Note::find(1);
$note->card_id = '1';
$note->save();

Upvotes: 1

You can use Note model to update the card_id value.

$note = Note::find(1);
$note->update([
    'card_id' => '1',
]); 

Upvotes: 0

Related Questions