defstudio / telegraph

Telegraph is a Laravel package for fluently interacting with Telegram Bots
MIT License
674 stars 116 forks source link

New Database #540

Closed Freshblood1121 closed 7 months ago

Freshblood1121 commented 7 months ago

Hello, can you please tell me, how can I make an entry in my database table? I have a table "telegraph_chats", "telegraph_bots" and my "users" table - where there are no records and there is no way to create them. I can write data to a table where there is an id

/** @var \DefStudio\Telegraph\Models\TelegraphChat $telegraphChat */
$telegraphChat = TelegraphChat::all();
$telegraphChat->last_message = 'Bye!';
$telegraphChat->save();

But I can't fill out a table that doesn't have any entries yet.

/** @var \App\Models\User $teleUser */
$teleUser = User::all();                               <=========== here
$teleUser->birthday = '2000.02.01';
$teleUser->save();

10 11

These methods don't work:

\App\Models\User::create([                     $userVar = new \App\Models\User();
         'birthday' => '2000.02.01',              $userVar->birthday = '2000.02.01';
]);                                                              $userVar->save();

Or how to make sure that when creating an entry in the telegraph_chats table, an entry is created in the users table

Thank you in advance for your help

Freshblood1121 commented 7 months ago

Okay, I should have deleted it newFactory() in Users model:)