n7olkachev / laravel-computed-properties Goto Github PK
View Code? Open in Web Editor NEWMake your accessors smarter
Make your accessors smarter
https://twitter.com/davidgolsen/status/920941756681719809
I wholeheartedly agree as it fits right in and should be a standard feature :) Perhaps create a laravel/internals issue or submit a PR in the hopes it gets accepted faster?
How is this package any better than just doing something like the below:
public function getSumAttribute()
{
return $this->rememberAs('sum', function() {
OrderProduct::select(new Expression('sum(price * count)'))
->where('order_id', $this->id);
});
}
If you have a basic implementation of rememberAs
on your model which sees if the key already exists and if not, run the closure and set the value on the model.
I assume the computed
name has come from the world of Vue.
Computed properties in Vue react to data that changes on the model, so if you were to update anything in which the computed property used, it will re-compute the computed property.
This is more of a 'watch out' type warning to people thinking it's 'real' computed properties (as they know it) from Vue.
composer require n7olkachev/laravel-computed-properties
Using version ^1.1 for n7olkachev/laravel-computed-properties
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework v5.6.26
- Conclusion: don't install laravel/framework v5.6.26
- n7olkachev/laravel-computed-properties v1.1.0 requires illuminate/config ~5.4.0 -> satisfiable by illuminate/config[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9].
- n7olkachev/laravel-computed-properties v1.1.1 requires illuminate/config ~5.4.0|~5.5.0 -> satisfiable by illuminate/config[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v
5.5.36, v5.5.37, v5.5.39, v5.5.40].
- don't install illuminate/config v5.4.0|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.4.13|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.4.17|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.4.19|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.4.27|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.4.36|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.4.9|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.0|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.16|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.17|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.2|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.28|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.33|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.34|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.35|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.36|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.37|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.39|don't install laravel/framework v5.6.26
- don't install illuminate/config v5.5.40|don't install laravel/framework v5.6.26
- Installation request for laravel/framework (locked at v5.6.26, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.26].
- Installation request for n7olkachev/laravel-computed-properties ^1.1 -> satisfiable by n7olkachev/laravel-computed-properties[v1.1.0, v1.1.1].
Installation failed, reverting ./composer.json to its original content.
I found this while trying to install the update with the package.
Luckily I haven't started using it yet!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.