Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Auth/Capability.php
#	src/Auth/RoleRegistration.php
#	src/Builders/CapabilityBuilder.php
#	src/Builders/RoleBuilder.php
#	src/CapabilitiesServiceProvider.php
#	src/Concerns/HasRoles.php
#	src/Configurations/RoleConfiguration.php
#	tests/Feature/CapabilityBuilderTest.php
#	tests/Feature/RoleAssignmentTest.php
#	tests/Fixtures/Models/User.php
#	tests/Fixtures/Roles/AdminRole.php
#	tests/Fixtures/Roles/MemberRole.php
  • Loading branch information
lukas-frey committed Oct 16, 2024
2 parents d9cd0ca + fb0bbbe commit c39dbd0
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 40 deletions.
2 changes: 0 additions & 2 deletions src/Contracts/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@

interface Role
{

public function getName(): string;

}
4 changes: 2 additions & 2 deletions tests/Fixtures/Models/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Document extends Model {
class Document extends Model
{
use HasFactory;
use HasRolesAndCapabilities;

Expand All @@ -15,5 +16,4 @@ class Document extends Model {
];

public $timestamps = false;

}
4 changes: 2 additions & 2 deletions tests/Fixtures/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Post extends Model {
class Post extends Model
{
use HasFactory;
use HasRolesAndCapabilities;

Expand All @@ -15,5 +16,4 @@ class Post extends Model {
];

public $timestamps = false;

}
6 changes: 2 additions & 4 deletions tests/Fixtures/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

namespace Tests\Fixtures\Models;

use Guava\Capabilities\Concerns\HasRolesAndCapabilities;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Role extends \Guava\Capabilities\Models\Role {
class Role extends \Guava\Capabilities\Models\Role
{
use HasFactory;

}
5 changes: 2 additions & 3 deletions tests/Fixtures/Models/Tenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

namespace Tests\Fixtures\Models;

use Guava\Capabilities\Concerns\HasRolesAndCapabilities;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Tenant extends Model {
class Tenant extends Model
{
use HasFactory;

protected $fillable = [
'name',
];

public $timestamps = false;

}
6 changes: 2 additions & 4 deletions tests/Fixtures/database/factories/DocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace Tests\Database\Factories;

use Guava\Capabilities\Models\Role;
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\Fixtures\Models\Document;
use Tests\Fixtures\Models\User;

class DocumentFactory extends Factory {

class DocumentFactory extends Factory
{
protected $model = Document::class;

public function definition()
Expand Down
7 changes: 2 additions & 5 deletions tests/Fixtures/database/factories/PostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

namespace Tests\Database\Factories;

use Guava\Capabilities\Models\Role;
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\Fixtures\Models\Document;
use Tests\Fixtures\Models\Post;
use Tests\Fixtures\Models\User;

class PostFactory extends Factory {

class PostFactory extends Factory
{
protected $model = Post::class;

public function definition()
Expand Down
5 changes: 2 additions & 3 deletions tests/Fixtures/database/factories/RoleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use Guava\Capabilities\Models\Role;
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\Fixtures\Models\User;

class RoleFactory extends Factory {

class RoleFactory extends Factory
{
protected $model = Role::class;

public function definition()
Expand Down
5 changes: 2 additions & 3 deletions tests/Fixtures/database/factories/TenantFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\Fixtures\Models\Tenant;
use Tests\Fixtures\Models\User;

class TenantFactory extends Factory {

class TenantFactory extends Factory
{
protected $model = Tenant::class;

public function definition()
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\Fixtures\Models\User;

class UserFactory extends Factory {

class UserFactory extends Factory
{
protected $model = User::class;

public function definition()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php


use Guava\Capabilities\Models\Capability;
use Guava\Capabilities\Models\Role;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class extends Migration
{
public function up()
{

Expand All @@ -28,35 +28,40 @@ public function up()
$table->foreignIdFor(config('capabilities.tenant_class'))
->nullable()
->constrained()
->cascadeOnDelete();
->cascadeOnDelete()
;
}
});

Schema::create('assigned_capabilities', function (Blueprint $table) {
$table->foreignIdFor(Capability::class)
->constrained()
->cascadeOnDelete();
->cascadeOnDelete()
;
$table->morphs('assignee');

if (config('capabilities.tenancy', false)) {
$table->foreignIdFor(config('capabilities.tenant_class'))
->nullable()
->constrained()
->cascadeOnDelete();
->cascadeOnDelete()
;
}
});

Schema::create('assigned_roles', function (Blueprint $table) {
$table->foreignIdFor(Role::class)
->constrained()
->cascadeOnDelete();
->cascadeOnDelete()
;
$table->morphs('assignee');

if (config('capabilities.tenancy', false)) {
$table->foreignIdFor(config('capabilities.tenant_class'))
->nullable()
->constrained()
->cascadeOnDelete();
->cascadeOnDelete()
;
}
});
}
Expand Down
4 changes: 1 addition & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

namespace Tests;

use Closure;
use Guava\Capabilities\CapabilitiesServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Schema\Blueprint;
use Orchestra\Testbench\TestCase as Orchestra;
use Guava\Capabilities\CapabilitiesServiceProvider;
use Tests\Fixtures\Models\Tenant;
use Tests\Fixtures\Models\User;

Expand Down

0 comments on commit c39dbd0

Please sign in to comment.