Skip to content

Commit 84eeb57

Browse files
authored
Merge branch '3.x' into fix-availability-override
2 parents cc8b474 + 8611299 commit 84eeb57

37 files changed

+170
-142
lines changed

CHANGELOG.md

Lines changed: 115 additions & 80 deletions
Large diffs are not rendered by default.

docs/content/2_guides/1_page-builder-with-blade/4_creating-the-page-module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ return new class extends Migration
254254
```
255255

256256
This file will create the minimum required tables and columns that Twill uses to provide the CMS functionality. Later in
257-
the guide we may add some more fields to the database, but will will do that in a new migration.
257+
the guide we may add some more fields to the database, but we will do that in a new migration.
258258

259259
Once you are more experienced with Twill, you may want to add fields at this moment, before you run the migrate command.
260260
That way, you do not have to immediately add a new migration file.

frontend/js/store/modules/buckets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const actions = {
6666
content_type: state.dataSources.selected.value,
6767
page: state.page,
6868
offset: state.offset,
69-
filter: state.filter
69+
filter: JSON.stringify(state.filter)
7070
}, resp => {
7171
commit(BUCKETS.UPDATE_BUCKETS_DATA, resp.source)
7272
commit(BUCKETS.UPDATE_BUCKETS_MAX_PAGE, resp.maxPage)

frontend/js/store/modules/datatable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const actions = {
231231
page: state.page,
232232
offset: state.offset,
233233
columns: getters.visibleColumnsNames,
234-
filter: state.filter
234+
filter: JSON.stringify(state.filter)
235235
}
236236

237237
api.get(params, function (resp) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@area17/twill",
3-
"version": "3.1.0",
3+
"version": "3.2.1",
44
"private": true,
55
"scripts": {
66
"inspect": "vue-cli-service inspect --mode production",

src/AuthServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace A17\Twill;
44

55
use A17\Twill\Facades\TwillPermissions;
6-
use A17\Twill\Models\User;
76
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
87
use Illuminate\Support\Facades\Gate;
98

@@ -159,7 +158,7 @@ public function boot()
159158

160159
$this->define('publish-user', function ($user) {
161160
return $this->authorize($user, function ($user) {
162-
$editedUserObject = User::find(request('id'));
161+
$editedUserObject = twillModel('user')::find(request('id'));
163162
return $this->userHasRole(
164163
$user,
165164
[TwillPermissions::roles()::ADMIN]

src/Commands/ListBlocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function getBlocks(): Collection
104104
// We do not render this.
105105
unset($data['rules'], $data['rulesForTranslatedFields']);
106106

107-
$data['block class'] = $block::class !== 'A17\Twill\Services\Blocks\Block' ? get_class($block) : 'default';
107+
$data['block class'] = $block::class !== Block::class ? get_class($block) : 'default';
108108

109109
$list[] = $data;
110110
}

src/Helpers/helpers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use A17\Twill\Facades\TwillBlocks;
44
use A17\Twill\Facades\TwillCapsules;
5+
use A17\Twill\Models\Model;
56
use A17\Twill\Services\Blocks\Block;
67
use Illuminate\Filesystem\Filesystem;
78
use Illuminate\Support\Arr;
@@ -208,6 +209,7 @@ function fix_directory_separator($path)
208209
}
209210

210211
if (! function_exists('twillModel')) {
212+
/** @return class-string<Model>|Model It returns a class string but this is for the correct type hints */
211213
function twillModel($model): string
212214
{
213215
return config("twill.models.$model")

src/Http/Controllers/Admin/ModuleController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use A17\Twill\Models\Behaviors\HasSlug;
1010
use A17\Twill\Models\Contracts\TwillModelContract;
1111
use A17\Twill\Models\Contracts\TwillSchedulableModel;
12-
use A17\Twill\Models\Group;
1312
use A17\Twill\Repositories\ModuleRepository;
1413
use A17\Twill\Services\Breadcrumbs\Breadcrumbs;
1514
use A17\Twill\Services\Forms\Fields\BaseFormField;
@@ -2674,7 +2673,7 @@ protected function respondWithJson($message, $variant)
26742673
protected function getGroupUserMapping()
26752674
{
26762675
if (config('twill.enabled.permissions-management')) {
2677-
return Group::with('users')->get()
2676+
return twillModel('group')::with('users')->get()
26782677
->mapWithKeys(function ($group) {
26792678
return [$group->id => $group->users()->pluck('id')->toArray()];
26802679
})->toArray();

src/Http/Controllers/Admin/ResetPasswordController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace A17\Twill\Http\Controllers\Admin;
44

5-
use A17\Twill\Models\User;
65
use Illuminate\Config\Repository as Config;
76
use Illuminate\Foundation\Auth\ResetsPasswords;
87
use Illuminate\Http\Request;
@@ -82,7 +81,7 @@ public function broker()
8281

8382
protected function sendResetResponse(Request $request, $response)
8483
{
85-
$user = User::where('email', $request->input('email'))->first();
84+
$user = twillModel('user')::where('email', $request->input('email'))->first();
8685
if (!$user->isActivated()) {
8786
$user->registered_at = Carbon::now();
8887
$user->save();
@@ -156,12 +155,12 @@ private function getUserFromToken($token)
156155
$clearToken = DB::table($this->config->get('auth.passwords.twill_users.table', 'twill_password_resets'))->where('token', $token)->first();
157156

158157
if ($clearToken) {
159-
return User::where('email', $clearToken->email)->first();
158+
return twillModel('user')::where('email', $clearToken->email)->first();
160159
}
161160

162161
foreach (DB::table($this->config->get('auth.passwords.twill_users.table', 'twill_password_resets'))->get() as $passwordReset) {
163162
if (Hash::check($token, $passwordReset->token)) {
164-
return User::where('email', $passwordReset->email)->first();
163+
return twillModel('user')::where('email', $passwordReset->email)->first();
165164
}
166165
}
167166

src/Http/Controllers/Admin/UserController.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
use A17\Twill\Enums\PermissionLevel;
66
use A17\Twill\Facades\TwillPermissions;
77
use A17\Twill\Models\Contracts\TwillModelContract;
8-
use A17\Twill\Models\Group;
98
use A17\Twill\Models\Permission;
10-
use A17\Twill\Models\Role;
11-
use A17\Twill\Models\User;
129
use A17\Twill\Services\Listings\Columns\Image;
1310
use A17\Twill\Services\Listings\Columns\Text;
1411
use A17\Twill\Services\Listings\Filters\QuickFilter;
@@ -99,7 +96,7 @@ public function __construct(Application $app, Request $request, AuthFactory $aut
9996

10097
TwillPermissions::showUserSecondaryNavigation();
10198

102-
$this->filters['role'] = User::getRoleColumnName();
99+
$this->filters['role'] = twillModel('user')::getRoleColumnName();
103100
}
104101

105102
public function getIndexTableColumns(): TableColumns
@@ -137,7 +134,7 @@ public function getIndexTableColumns(): TableColumns
137134
);
138135
$tableColumns->add(
139136
Text::make()
140-
->field(User::getRoleColumnName())
137+
->field(twillModel('user')::getRoleColumnName())
141138
->title('Role')
142139
->customRender(function (TwillModelContract $user) {
143140
if (TwillPermissions::enabled()) {
@@ -325,7 +322,7 @@ public function resendRegistrationEmail($userId)
325322
private function getGroupPermissionMapping()
326323
{
327324
if (config('twill.enabled.permissions-management')) {
328-
return Group::with('permissions')->get()
325+
return twillModel('group')::with('permissions')->get()
329326
->mapWithKeys(function ($group) {
330327
return [$group->id => $group->permissions];
331328
})->toArray();
@@ -338,7 +335,7 @@ private function getGroups()
338335
{
339336
if (config('twill.enabled.permissions-management')) {
340337
// Forget first one because it's the "Everyone" group and we don't want to show it inside admin.
341-
return Group::with('permissions')->pluck('name', 'id')->forget(1);
338+
return twillModel('group')::with('permissions')->pluck('name', 'id')->forget(1);
342339
}
343340

344341
return [];
@@ -347,7 +344,7 @@ private function getGroups()
347344
private function getRoleList()
348345
{
349346
if (config('twill.enabled.permissions-management')) {
350-
return Role::accessible()->published()->get()->map(function ($role) {
347+
return twillModel('role')::accessible()->published()->get()->map(function ($role) {
351348
return ['value' => $role->id, 'label' => $role->name];
352349
})->toArray();
353350
}

src/Http/Requests/Admin/UserRequest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace A17\Twill\Http\Requests\Admin;
44

5-
use A17\Twill\Models\Role;
6-
use A17\Twill\Models\User;
75
use Illuminate\Support\Facades\Auth;
86
use Illuminate\Validation\Rule;
97
use PragmaRX\Google2FA\Google2FA;
@@ -58,7 +56,7 @@ public function rules(): array
5856
}
5957
},
6058
'force-2fa-disable-challenge' => function ($attribute, $value, $fail) {
61-
$user = User::findOrFail($this->route('user'));
59+
$user = twillModel('user')::findOrFail($this->route('user'));
6260
if ($this->get('google_2fa_enabled') || ! $user->google_2fa_enabled) {
6361
return;
6462
}
@@ -95,12 +93,12 @@ private function getRoleValidator($baseRule = [])
9593
{
9694
if (config('twill.enabled.permissions-management')) {
9795
// Users can't assign roles above their own
98-
$accessibleRoleIds = Role::accessible()->pluck('id')->toArray();
96+
$accessibleRoleIds = twillModel('role')::accessible()->pluck('id')->toArray();
9997
$baseRule[] = Rule::in($accessibleRoleIds);
10098
} else {
10199
$baseRule[] = 'not_in:SUPERADMIN';
102100
}
103101

104-
return [User::getRoleColumnName() => $baseRule];
102+
return [twillModel('user')::getRoleColumnName() => $baseRule];
105103
}
106104
}

src/Models/Revision.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(array $attributes = [])
2929

3030
public function user()
3131
{
32-
return $this->belongsTo(User::class);
32+
return $this->belongsTo(twillModel('user'));
3333
}
3434

3535
public function getByUserAttribute()

src/Models/Role.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function scopeOnlyTrashed($query): Builder
7474

7575
public function users(): HasMany
7676
{
77-
return $this->hasMany(User::class);
77+
return $this->hasMany(twillModel('user'));
7878
}
7979

8080
public function getCreatedAtAttribute($value): string

src/Models/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function sendPasswordResetByAdminNotification($password)
244244

245245
public function groups()
246246
{
247-
return $this->belongsToMany(Group::class, 'group_twill_user', 'twill_user_id', 'group_id');
247+
return $this->belongsToMany(twillModel('group'), 'group_twill_user', 'twill_user_id', 'group_id');
248248
}
249249

250250
public function publishedGroups()
@@ -254,7 +254,7 @@ public function publishedGroups()
254254

255255
public function role()
256256
{
257-
return $this->belongsTo(Role::class);
257+
return $this->belongsTo(twillModel('role'));
258258
}
259259

260260
public function allPermissions()

src/Models/UserOauth.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace A17\Twill\Models;
44

5-
use A17\Twill\Models\User;
65
use Illuminate\Database\Eloquent\Model as BaseModel;
76

87
class UserOauth extends BaseModel
@@ -24,6 +23,6 @@ public function __construct(array $attributes = [])
2423

2524
public function user()
2625
{
27-
$this->belongsTo(User::class, 'user_id');
26+
$this->belongsTo(twillModel('user'), 'user_id');
2827
}
2928
}

src/Repositories/UserRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use A17\Twill\Facades\TwillPermissions;
66
use A17\Twill\Models\Contracts\TwillModelContract;
77
use A17\Twill\Models\User;
8-
use A17\Twill\Models\Group;
98
use A17\Twill\Repositories\Behaviors\HandleMedias;
109
use A17\Twill\Repositories\Behaviors\HandleOauth;
1110
use A17\Twill\Repositories\Behaviors\HandleUserPermissions;
@@ -79,10 +78,11 @@ public function getFormFieldsForBrowser(
7978
$browserFields = parent::getFormFieldsForBrowser($object, $relation, $routePrefix, $titleKey, $moduleName);
8079

8180
if (TwillPermissions::enabled()) {
81+
$everyoneGroup = twillModel('group')::getEveryoneGroup();
8282
foreach ($browserFields as $index => $browserField) {
8383
if (
84-
$browserField['id'] === Group::getEveryoneGroup()->id &&
85-
$browserField['name'] === Group::getEveryoneGroup()->name
84+
$browserField['id'] === $everyoneGroup->id &&
85+
$browserField['name'] === $everyoneGroup->name
8686
) {
8787
$browserFields[$index]['edit'] = false;
8888
$browserFields[$index]['deletable'] = false;

src/TwillServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TwillServiceProvider extends ServiceProvider
5858
*
5959
* @var string
6060
*/
61-
public const VERSION = '3.1.0';
61+
public const VERSION = '3.2.1';
6262

6363
/**
6464
* Service providers to be registered.

twill-assets/assets/twill/css/chunk-common.7b8b9f7b.css renamed to twill-assets/assets/twill/css/chunk-common.25d62781.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)