use BookStack\Auth\Role;
use BookStack\Entities\Entity;
use BookStack\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\MorphOne;
class JointPermission extends Model
{
+ protected $primaryKey = null;
public $timestamps = false;
/**
* Get the role that this points to.
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
- public function role()
+ public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
/**
* Get the entity this points to.
- * @return \Illuminate\Database\Eloquent\Relations\MorphOne
*/
- public function entity()
+ public function entity(): MorphOne
{
return $this->morphOne(Entity::class, 'entity');
}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class DropJointPermissionsId extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('joint_permissions', function (Blueprint $table) {
+ $table->dropColumn('id');
+ $table->primary(['role_id', 'entity_type', 'entity_id', 'action'], 'joint_primary');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('joint_permissions', function (Blueprint $table) {
+ $table->dropPrimary(['role_id', 'entity_type', 'entity_id', 'action']);
+ });
+
+ Schema::table('joint_permissions', function (Blueprint $table) {
+ $table->increments('id')->unsigned();
+ });
+ }
+}
use BookStack\Entities\Bookshelf;
use BookStack\Entities\Page;
-use BookStack\Auth\Permissions\PermissionsRepo;
use BookStack\Auth\Role;
use Laravel\BrowserKitTesting\HttpException;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Tests\BrowserKitTest;
class RolesTest extends BrowserKitTest
private function addComment($page) {
$comment = factory(\BookStack\Actions\Comment::class)->make();
- $url = "/ajax/page/$page->id/comment";
+ $url = "/comment/$page->id";
$request = [
'text' => $comment->text,
'html' => $comment->html
private function updateComment($commentId) {
$comment = factory(\BookStack\Actions\Comment::class)->make();
- $url = "/ajax/comment/$commentId";
+ $url = "/comment/$commentId";
$request = [
'text' => $comment->text,
'html' => $comment->html
}
private function deleteComment($commentId) {
- $url = '/ajax/comment/' . $commentId;
+ $url = '/comment/' . $commentId;
return $this->json('DELETE', $url);
}