Releases: RonasIT/laravel-helpers
Requirements update
- removed requiring minime/annotations package;
- set guzzle package requiement to min 6.0
Small fixes
- fixed bug with scopeOrderByRelated method in Laravel 8
Collection update
- increased required Laravel version up to 5.4 instead of 5.2;
- increased required php version up to 7.1 instead of 7.0;
- update methods and arguments typing;
- moved default empty rules method to the BaseRequest class;
- removed all deprecated classes;
- updated HttpRequestService class: renamed all base methods, removed
send
prefix, also now it works in chain mode
$result = app(HttpRequestService::class)->get($url)->json();
$response = app(HttpRequestService::class)->post($url, $data)->getResponse();
- removed deprecated methods;
- Implemented
MockClassTrait
class
use MockClassTrait;
pubic function testCreate()
{
$this->mockClass(UserService::class, [
['method' => 'generateHash', 'result' => $hash]
]);
}
- removed legacy
setForceVisibleFields
/setForceHiddenFields
- updated result format of
SearchTrait
/EntityControlTrait
from arrays to Collection/Model/null; - removed duplicated
with
/withRelations
andwithCount
/withRelationsCount
methods
$this->with('role')->withCount('images')->find($id)
$this
->with(Are::get($filters, 'with'))
->withCount(Are::get($filters, 'with_count'))
->searchQuery($filters)
->getSearchResults();
- implemented new
extract_last_part
helper
$path = 'user.setting.name'
list($path, $lastPart) = extract_last_part($path);
//$path = 'user.setting'
//$lastPart = 'name'
Export mode update
- Method
assertEqualsFixture
now has the third argument$exportMode = false
, set it totrue
to export expected data to the fixture from the first argument and don't forget to remove it after :) - Renamed some methods;
- Removed strict types from the base repository methods (strict types will be reverted after major version)
Hide/Show update
- Implemented new methods that allow hiding/showing fields from the result:
Method makeHidden($fields)
will hide fields from the attribute from the result.
app(OrderService::class)->makeHidden(['fee', 'personal_fee'])->get();
it also will work with the single field name
app(OrderService::class)->makeHidden('discount_percent')->first($id);
Method makeVisible($fields)
will show hidden in the model class fields from the attribute in the result.
app(UserService::class)->makeVisible('password')->find($id);
Both methods work on the collection level, so it wouldn't modify the select
clause of your query.
- Extended
updateMany
method
Now it has the third argument that allows you to specify whether to return affected rows or affected rows count
app(CategoryService::class)->updateMany(['is_global' => false], ['is_global' => true], true)
It also returns correct results now (fixed bug with unexpected affected rows in the result).
As now updateMany
method works via the chunk
method (to save updated ids before the update, it will skip with $updatedRecordsAsResult = false
) - it has the fought argument to set the limit per chunk
app(CategoryService::class)->updateMany(['is_global' => false], ['is_global' => true], true)
-
For the Laravel 8 and later
getSearchResults
method with flagall = true
will return the same pagination format as forpage/per_page
flags. -
Fixed bug with nonworking
filterByQuery()
method with the integer field in argument (in Postgre SQL)
$this->searchQuery($filters)->filterByQuery(['id'])->getSearchResults()
now will work fine
-
set types for
EntityControlTrait
methods and arguments -
small fixes
1.5.0: Merge pull request #11 from RonasIT/dpankratov/version-update
- increased minime/annotations package min version;
- added sorting by the field length result of the
onlyValidated
method; - updated BaseExporter class to able to set disk for the storing exported files;
- renamed
unique_except_of_current_user
validation rule to theunique_except_of_authorized_user
(Breaking change) - fixed
withRelationsCount
method logic, now it will work correctly with the dot notation
app(UserService::class)->withCount(['contact.addressed'])->get()
withRelationsCount
andwithRelations
now will wrap argument to an array, so the next construction will work correctly now
app(UserService::class)->withRelations('roles')->first()
- fixed logic of the
firstOrCreate
method, now fields from the second argument are priority than from the first; callRawRequest
now will return$this
context;- failing tests with the export JSON mode will now occur in export content method (not only JSON);
- big update of
assertMailEquals
method, able to redefine some default checks and implement custom, implemented validation of input params;
BaseRequest update
- added new BaseRequest class with
onlyValidated
method; - removed
beta
tag;
updateMany fix
- added an ability to use dot notation in
fieldName
argument of theupdateMany
method
Syntax update
- changed
array_*
andstr_*
helpers functions to facade methodsArr::*
andStr::*
; - added annotations to some methods;
- added php 7 types to some methods;
- implemented
chunk
method; - fixed bug with incorrect page urls with using
all
flag in the search method; - fixed
orderBy
method, now it callsorderBy
ororderByRelated
instead of onlyorderByRelated
;
Order by relation field fix
- fixed bug with the order by field of the relation with the additional where clause;