Eloquent touch() and $touches: Update Timestamps

Eloquent touch() and $touches: Update Timestamps

Laravel Daily

1 год назад

7,893 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@user-xe7gv2nf5n
@user-xe7gv2nf5n - 02.10.2022 08:01

first, good morning !

Ответить
@abulfaisalshourab3840
@abulfaisalshourab3840 - 02.10.2022 08:01

Your videos are amazing and very informative ❤️

Ответить
@superuser6718
@superuser6718 - 02.10.2022 08:03

Wow nice 👍

Ответить
@jkevinparker
@jkevinparker - 02.10.2022 08:10

Makes sense. Almost like a “verified at” time stamp.

Ответить
@AliAwwad
@AliAwwad - 02.10.2022 08:26

Very useful , never new it was there . Thank you

Ответить
@TopperTube
@TopperTube - 02.10.2022 10:05

Nice !
I think I made the same functionality on my own.
Didn't know it was already in Laravel. 😅

Ответить
@learn-from-my-mistakes
@learn-from-my-mistakes - 02.10.2022 10:59

Very informative. Thank you.

Ответить
@Ghost-hz2dy
@Ghost-hz2dy - 02.10.2022 11:00

Hello, If you can please review my package

shergela/laravel-command

Ответить
@kingstalker
@kingstalker - 02.10.2022 11:38

How to structure recurable invoices and what if product got deleted after first invoice or if you have a custom invoice what if product 1 is recurable and product 2 is a service and its monthly and custom item 3 is recurable weekly I really need help on this please

Ответить
@kwameadoko9542
@kwameadoko9542 - 02.10.2022 12:49

I just don’t know what to say practically 😊🎉❤

Ответить
@vanvanni_nl
@vanvanni_nl - 02.10.2022 14:18

These short videos are perfect!

Ответить
@IlPandax
@IlPandax - 02.10.2022 15:06

Every day you publish a video. Every day I know what you are talking about and you teach me some new detail I don't know. Today you published a video about something I completely didn't know! Thanks man! ;)

Ответить
@lucasj.pereira4912
@lucasj.pereira4912 - 02.10.2022 15:53

Now it would be even better if you could use an array: $model->touch(['agent_read_at', 'last_message_at']);

Ответить
@GergelyCsermely
@GergelyCsermely - 02.10.2022 18:21

Thanks

Ответить
@benyaminbolhassani3708
@benyaminbolhassani3708 - 02.10.2022 20:14

whats the diffrence between touch and refresh method ? ex ( $user=User::find(*)->refresh();

Ответить
@HadToChangeMyName_YoutubeSucks
@HadToChangeMyName_YoutubeSucks - 02.10.2022 23:17

I've never actually understood the point of the timestamps being written by the application, at least not by default. That's something you should have to turn on, not turn off. Why would you not just create a not null default timestamp column and another with on update timestamp and let the server deal with those? What am I missing about this? Is this just a little helper thing for people who are databasing and don't really know the basics of database? There are always going to be date/timestamp columns that the application must set but to me neither the created nor updated columns are one of them. As far as updating related table dates that's exactly what a trigger is for (which is what column defaults actually are under the hood). The database server is expressly designed to do such things for a very good reason and it's generally going to be far more efficient at it than manually updating columns from the application side. Not saying there's no place for keeping all of the database work on the application and strictly using the database for data storage, but I think that just makes doing things the wrong way easier and it actually puts more load on both the application and the database server. My databases are all full of triggers as well as procedures that attend to scenarios where if X happens Y has to happen and all of the data needed to do it is already in the DB. If adding to an invoice has to increase some number in some other table by that amount it would be silly to fetch the second number from the db, add it to the line item amount and then resave the new number, the database server could finish doing that and be back to playing solitaire before you even got the second number back from the DB. It's wasteful of resources, and if numerous things have to follow from an action it makes manually inserting/updating records directly at the database end far more complicated and prone to mistakes, if you've let the database do these things you can just insert a new row in the invoice table manually or from a csv and everything happens as it's intended to happen.

Ответить
@free2idol1
@free2idol1 - 03.10.2022 05:21

apart from updated_at/created_at, do you know any scenario where "timestamp" data type is used? I was known that datetime should be used for a majority of scenarios.

Ответить
@naojamg
@naojamg - 03.10.2022 10:09

wow I've never used touch before but I'll definitely give it a try :o thanks man :D

Ответить
@nicolegeorge8659
@nicolegeorge8659 - 03.10.2022 18:59

Wow! Very informative 👏 thanks man

Ответить
@LaercioLopesLL
@LaercioLopesLL - 03.10.2022 19:46

Thankyou Povilas

Ответить
@mc9652
@mc9652 - 03.10.2022 19:56

I've used touch method to trigger updated/updating events in model observers

Ответить
@mohamedtarek-fk8sc
@mohamedtarek-fk8sc - 10.10.2022 08:19

Can anyone give me example to use touch function ?? Or in which case the update of the updated at will help ?? Thank you in advance.

Ответить
@user-by3oc2pd5b
@user-by3oc2pd5b - 16.01.2024 18:53

Thank you so much for the info!

Ответить
@user-by3oc2pd5b
@user-by3oc2pd5b - 16.01.2024 18:53

👏👏Thank you so much Povilas!

Ответить