Init
This commit is contained in:
23
Career/Resources/Laracast/Eloquent Performance Patterns.md
Normal file
23
Career/Resources/Laracast/Eloquent Performance Patterns.md
Normal file
@@ -0,0 +1,23 @@
|
||||
### Getting one recode from a has many relation
|
||||
addSelect(['value_name' => Model::whereColumn('a','table.b')->take(1)])
|
||||
|
||||
|
||||
|
||||
### Dynamic Relationships Using Subqueries
|
||||
The relation column can be added using a addSelect
|
||||
|
||||
### Calculate Totals Using Conditional Aggregates
|
||||
case exists
|
||||
|
||||
### Optimize Circular Relationships
|
||||
Manual set relation to the model instead of loading it again
|
||||
|
||||
### Getting LIKE to use an Index
|
||||
Dont use wildcards on both sides
|
||||
|
||||
### Use Unions to Run Queries Independently
|
||||
Where in
|
||||
derived table
|
||||
find users by x
|
||||
union
|
||||
find users by y
|
||||
@@ -0,0 +1 @@
|
||||
bla
|
||||
@@ -0,0 +1,4 @@
|
||||
You can make most populair articles with redis, it has (sorted) lists, hashmap etc.
|
||||
|
||||
Move stuff you want to cache in a repository, maybe with a non cached version.
|
||||
|
||||
19
Career/Resources/Laracast/Modular Laravel.md
Normal file
19
Career/Resources/Laracast/Modular Laravel.md
Normal file
@@ -0,0 +1,19 @@
|
||||
He put everything in a modules folder / namespace. Inside a module the default Laravel structure is use.
|
||||
|
||||
Each module gets a service provider, with a loadMigrationsFrom, mergeConfigFrom and registers other providers.
|
||||
|
||||
Each model gets a route service provider.
|
||||
Each model gets a event service provider.
|
||||
|
||||
Tests are put in the modules and bound in the phpunit.xml. FYI starts are followed
|
||||
'/modules/\*/Test' works. Also add modules specific base test case.
|
||||
|
||||
To bind factory, define model and newFactory method.
|
||||
|
||||
When you need to use models from other modules, instead use Data Transfer Objects which can then be used to encapsulate behaviour.
|
||||
|
||||
Make your dto's readonly and enforce properties to be primitives. When breaking a boundary a easy fix would be to make placeholder class a module and inject it into the other module.
|
||||
|
||||
Then behaviour is put into actions.
|
||||
|
||||
To uncoupling make dto's from your models and start moving all the things you need into those dtos
|
||||
Reference in New Issue
Block a user