andersao / andersao/l5-repository
overwrite select columns by a criteria
- Vorherrschende Sprache
- PHP
- Sterne
- 4.2k
- Forks
- 880
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
When I have a criteria like:
```php
public function apply($model, RepositoryInterface $repository)
{
return $model->leftJoin('deals', 'deals.country_id', '=', 'countries.id')
->addSelect(\DB::raw('count(deals.id) as deals_count'))
->groupBy('countries.id')
->orderBy('deals_count', 'desc');
}
```
then we cant specified columns when `->all($columns)` is fired.
```php
$countryRepositoryEloquent->resetCriteria();
//$countryRepositoryEloquent->select(['countries.*']);
$countryRepositoryEloquent->pushCriteria(CountryWithDealsCountCriteria::class);
return $countryRepositoryEloquent->all();
```
A fields pushed in Criteria overwrites default columns from a model :(
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.