Skip to content

Commit b605d00

Browse files
authored
Merge pull request #18091 from craftcms/feature/user-query
[6.x] UserQuery, AddressQuery & ContentBlockQuery
2 parents 5baf4e4 + e540016 commit b605d00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2780
-86
lines changed

CHANGELOG-WIP.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Release Notes for Craft CMS 6.0 (WIP)
22

3-
### Development
3+
## Development
44
- Reference tags now support fallback values when no attribute is specified. ([#17688](https://github.com/craftcms/cms/pull/17688))
55
- Deprecated support for categories, global sets, and tags. ([#18009](https://github.com/craftcms/cms/pull/18009))
66

7-
### Extensibility
7+
## Extensibility
88
- Added `CraftCms\Cms\Support\Arr`.
99
- Added `CraftCms\Cms\Support\Str`.
1010
- `craft\services\Elements::stopCollectingCacheInfo()` no longer sets the returned duration to the `cacheDuration` config setting if a duration wasn’t explicitly declared. ([#16796](https://github.com/craftcms/cms/pull/16796))
@@ -140,6 +140,16 @@ Craft's Mutex classes have been deprecated. [Laravel's atomic locking](https://l
140140
- Deprecated `craft\events\DefineSourceSortOptionsEvent`. `CraftCms\Cms\Element\Events\DefineSourceSortOptions` should be used instead.
141141
- Deprecated `craft\events\DefineSourceTableAttributesEvent`. `CraftCms\Cms\Element\Events\DefineSourceTableAttributes` should be used instead.
142142

143+
## Element Queries
144+
145+
- Deprecated `\craft\elements\db\AddressQuery`. `\CraftCms\Cms\Database\Queries\AddressQuery` should be used instead.
146+
- Deprecated `\craft\elements\db\AssetQuery` `\CraftCms\Cms\Database\Queries\AssetQuery` should be used instead.
147+
- Deprecated `\craft\elements\db\ContentBlockQuery` `\CraftCms\Cms\Database\Queries\ContentBlockQuery` should be used instead.
148+
- Deprecated `\craft\elements\db\ElementQuery` `\CraftCms\Cms\Database\Queries\ElementQuery` should be used instead.
149+
- Deprecated `\craft\elements\db\ElementQueryInterface`
150+
- Deprecated `\craft\elements\db\EntryQuery` `\CraftCms\Cms\Database\Queries\EntryQuery` should be used instead.
151+
- Deprecated `\craft\elements\db\UserQuery` `\CraftCms\Cms\Database\Queries\UserQuery` should be used instead.
152+
143153
## Entries & Entry Types
144154

145155
- Deprecated `craft\services\Entries`. `CraftCms\Cms\Entry\Entries` and `CraftCms\Cms\Entry\EntryTypes` should be used instead.
@@ -156,31 +166,48 @@ Craft's Mutex classes have been deprecated. [Laravel's atomic locking](https://l
156166
- Removed `craft\console\controllers\EntryTypesController` in favor of:
157167
- `CraftCms\Cms\Entry\Commands\MergeEntryTypesCommand`
158168

159-
### Plugins
169+
## Migrations
170+
171+
Craft and Yii's migrations have been removed in favor of [Laravel migrations](https://laravel.com/docs/12.x/migrations).
172+
173+
The `php craft fields:merge` and `php craft entry-types:merge` commands will now generate Laravel migrations.
160174

161-
#### Added
175+
- Deprecated `craft\db\Migration`. `CraftCms\Cms\Database\Migration` should be used instead.
176+
- Deprecated `craft\db\MigrationManager`
177+
- Removed `craft\helpers\MigrationHelper` as it was deprecated since 4.0.0.
178+
- Removed `craft\console\controllers\InstallController` in favor of:
179+
- `CraftCms\Cms\Console\Commands\InstallCommand`
180+
- `CraftCms\Cms\Console\Commands\InstallCheckCommand`
181+
- Removed `craft\console\controllers\MigrateController` in favor of:
182+
- `CraftCms\Cms\Database\Commands\MigrateCommand`
183+
- Removed `craft\console\controllers\UpController` in favor of:
184+
- `CraftCms\Cms\Console\Commands\UpCommand`
185+
186+
## Plugins
187+
188+
### Added
162189
- The base `CraftCms\Cms\Plugin\Plugin` class is now a [Laravel ServiceProvider](https://laravel.com/docs/12.x/providers) which provides a new way to register components for your plugins.
163190

164-
#### Deprecations
191+
### Deprecations
165192

166193
- Deprecated `craft\services\Plugins`. `CraftCms\Cms\Plugin\Plugins` should be used instead.
167194
- Deprecated `craft\base\Plugin`. `CraftCms\Cms\Plugin\Plugin` should be used instead.
168195
- Deprecated `craft\base\PluginTrait`.
169196
- Deprecated `craft\base\PluginInterface`. `CraftCms\Cms\Plugin\Contracts\PluginInterface` should be used instead.
170197
- Deprecated `craft\errors\InvalidPluginException`. `CraftCms\Cms\Plugin\Exceptions\InvalidPluginException` should be used instead.
171198

172-
#### Controllers
199+
### Controllers
173200
- Removed `craft\controllers\PluginsController`. Use `CraftCms\Cms\Http\Controllers\PluginsController` instead.
174201

175-
#### Commands
202+
### Commands
176203
- Removed `craft\console\controllers\PluginController` in favor of:
177-
- `CraftCms\Cms\Plugin\Commands\DisableCommand` -> `php craft plugin:disable`
178-
- `CraftCms\Cms\Plugin\Commands\EnableCommand` -> `php craft plugin:enable`
179-
- `CraftCms\Cms\Plugin\Commands\InstallCommand` -> `php craft plugin:install`
180-
- `CraftCms\Cms\Plugin\Commands\UninstallCommand` -> `php craft plugin:uninstall`
181-
- `CraftCms\Cms\Plugin\Commands\ListCommand` -> `php craft plugin:list`
182-
183-
#### Events
204+
- `CraftCms\Cms\Plugin\Commands\DisableCommand` -> `php craft plugin:disable`
205+
- `CraftCms\Cms\Plugin\Commands\EnableCommand` -> `php craft plugin:enable`
206+
- `CraftCms\Cms\Plugin\Commands\InstallCommand` -> `php craft plugin:install`
207+
- `CraftCms\Cms\Plugin\Commands\UninstallCommand` -> `php craft plugin:uninstall`
208+
- `CraftCms\Cms\Plugin\Commands\ListCommand` -> `php craft plugin:list`
209+
210+
### Events
184211
- Deprecated `craft\events\PluginEvent` in favor of the following new events:
185212
- `craft\base\Plugin::EVENT_BEFORE_SAVE_SETTINGS` => `CraftCms\Cms\Component\Events\ComponentEvent`
186213
- `craft\base\Plugin::EVENT_AFTER_SAVE_SETTINGS` => `CraftCms\Cms\Component\Events\ComponentEvent`
@@ -197,24 +224,7 @@ Craft's Mutex classes have been deprecated. [Laravel's atomic locking](https://l
197224
- `craft\services\Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS` => `CraftCms\Cms\Plugin\Events\PluginSettingsSaved`;
198225
- `craft\services\Plugins::EVENT_AFTER_UNINSTALL_PLUGIN` => `CraftCms\Cms\Plugin\Events\PluginUninstalled`;
199226

200-
### Migrations
201-
202-
Craft and Yii's migrations have been removed in favor of [Laravel migrations](https://laravel.com/docs/12.x/migrations).
203-
204-
The `php craft fields:merge` and `php craft entry-types:merge` commands will now generate Laravel migrations.
205-
206-
- Deprecated `craft\db\Migration`. `CraftCms\Cms\Database\Migration` should be used instead.
207-
- Deprecated `craft\db\MigrationManager`
208-
- Removed `craft\helpers\MigrationHelper` as it was deprecated since 4.0.0.
209-
- Removed `craft\console\controllers\InstallController` in favor of:
210-
- `CraftCms\Cms\Console\Commands\InstallCommand`
211-
- `CraftCms\Cms\Console\Commands\InstallCheckCommand`
212-
- Removed `craft\console\controllers\MigrateController` in favor of:
213-
- `CraftCms\Cms\Database\Commands\MigrateCommand`
214-
- Removed `craft\console\controllers\UpController` in favor of:
215-
- `CraftCms\Cms\Console\Commands\UpCommand`
216-
217-
### (Plugin) Updates
227+
## Updates
218228

219229
The `craft\services\Updates` internal service has been removed. `CraftCms\Cms\Updates\Updates` should be used instead.
220230

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CraftCms\Cms\Database\Factories;
6+
7+
use CraftCms\Cms\Addresses\Models\Address;
8+
use CraftCms\Cms\Element\Models\Element;
9+
use Illuminate\Database\Eloquent\Factories\Factory;
10+
use Override;
11+
12+
final class AddressFactory extends Factory
13+
{
14+
protected $model = Address::class;
15+
16+
#[Override]
17+
public function definition(): array
18+
{
19+
return [
20+
'id' => Element::factory()->set('type', \CraftCms\Cms\Element\Elements\Address::class),
21+
'countryCode' => fake()->countryCode(),
22+
'dateCreated' => $created = $this->faker->dateTime(),
23+
'dateUpdated' => $created,
24+
];
25+
}
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CraftCms\Cms\Database\Factories;
6+
7+
use CraftCms\Cms\User\Models\UserPermission;
8+
use Illuminate\Database\Eloquent\Factories\Factory;
9+
use Override;
10+
11+
final class UserPermissionFactory extends Factory
12+
{
13+
protected $model = UserPermission::class;
14+
15+
#[Override]
16+
public function definition(): array
17+
{
18+
return [
19+
'name' => $this->faker->word(),
20+
];
21+
}
22+
}

src/Addresses/Models/Address.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
use CraftCms\Cms\Database\Table;
88
use CraftCms\Cms\Shared\BaseModel;
99
use CraftCms\Cms\User\Models\User;
10+
use Illuminate\Database\Eloquent\Factories\HasFactory;
1011
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1112

1213
final class Address extends BaseModel
1314
{
15+
use HasFactory;
16+
1417
protected $table = Table::ADDRESSES;
1518

1619
/** @return BelongsTo<User, $this> */

0 commit comments

Comments
 (0)