Комментарии:
Nice video, but, what if i want to cast this attribute, or better said, i have it casted as date? im having this error and i dont know hot to solve it.
ОтветитьI've learned a lot from you in such a short time. Thanks a lot.
I haven't fully switched to this new approach, at least for the getter/accessor part, because I haven't found a way to not loose access to the original attribute value. I mean, the one that hasn't been modified by the accessor mechanism. At least with the getXXXAttribute() approach you can add a new attribute with a different name and you don't loose access to the original attribute value.
I followed you on Laracast aswell, Love your content btw... Just a question if you have a table "unit_price" in the migrations and a "tax" table. if i calc the tax amount how do a save it in the db ? because i get the tax amount witch is correct but it does not save in the db, sorry im still learning programming
ОтветитьWill your quickadminpanel be updated to reflect this method on generated code?
ОтветитьI like this approach, it's more elegant in deed. I have a question though, how can we add a custom field to the model?
Like when we have first_name and last_name fields in the database and we want to have the full_name attribute by joining the first two fields.
I like that Laravel is going more towards the C# way of doing things, but it seems this can ONLY be done with Models? Is that correct?
This is a Laravel specific implementation and not a PHP 8 implementation?
yeah i like this way, looks much clean, nice video
ОтветитьNo, will not be using this. Appreciate the option, but IMHO it is less readable, and I prefer to keep them separate. Most importantly, we've got several hundred of these across our apps, certainly not going to incur cost just to change to sugar. Unfortunate the docs will change - that means we have to train new devs into something that was standard until now. Not a big deal for one thing... but that creeps up on you when supporting legacy code bases.
ОтветитьLike vue computed get set, shorter and nicer. Loved it thanks for the update!
ОтветитьCool use of PHP8 named arguments.
ОтветитьI hope the old method doesn't go away. I like this new method for simple cases of setting custom casts. But there are sometimes where there is more logic behind the accessor and/or mutator and I think it's cleaner to separate them into their own methods, particularly when its not just a single line return.
I also wonder will this new method work if I only supply just a getter or just a setter, or if it requires both to be defined. For example I define a getter but no setter to create a psudo field that doesn't actually exist in the DB. I do that a lot to create a separate property for a display version of a value versus the calculable version (for example with currency having an integer in cents for storing/calculating on say an 'amount' property, but having a getter to make a formatted string for display using a made up property like 'amount_display').
Don't you lose any form of intellisense on this now? Or can you treat attribute like a genric in the docblock? (@returns Attribute<Carbon>)
I suppose you can still document the class to have the correct type for the property.
I have only one question. Why Laravel hates my code?
I had a model with field profit. And don't like Laravel's magic when I can call $model->profit to get the value. So I create a real method to call it $model->profit() and it returns a Decial object. But with this update, my method does not work anymore. Because it should return an Attribute.
So the changes are great but I think you should not do something like this in minor updates. Laravel 9 - sure, no problem. But updating Laravel 8 I expect my code to still work.
I like this new method. :)
Why didn't you use the Laravel method to parse dates directly, thought?
Sir! Сould you please make another great tutorial video about elegant way to filter and sort data in "api routes" with "index" method with optional query params?
For example: /products?orderBy=created_at&order=desc&created_at>=somedate&created_at<=somedate&category=[somearray with category names or ids]&name="Samsu%"&limit=20 etc
thank you!
Cool! Thank you!
Ответитьprefer old syle.
ОтветитьCan you tell me Which package was used to build the DataTable?
ОтветитьNice
ОтветитьGreat news, I didn't like the old version
Ответить