Skip to content

Commit

Permalink
Add Migration & Models
Browse files Browse the repository at this point in the history
  • Loading branch information
Obi-Wana committed Nov 6, 2024
1 parent 8eb1e64 commit e44b861
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ public function chatStatus(): \Illuminate\Database\Eloquent\Relations\BelongsTo
return $this->belongsTo(ChatStatus::class, 'chat_status_id', 'id');
}

/**
* Belongs to many Blocked Users.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<User, $this>
*/
public function blockedUsers(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(BlockedUsers::class, 'user_id', 'blocked_user_id')

Check failure on line 209 in app/Models/User.php

View workflow job for this annotation

GitHub Actions / php 8.3 on ubuntu-22.04

Class App\Models\BlockedUsers not found.

Check failure on line 209 in app/Models/User.php

View workflow job for this annotation

GitHub Actions / php 8.3 on ubuntu-22.04

Method App\Models\User::blockedUsers() should return Illuminate\Database\Eloquent\Relations\BelongsToMany<App\Models\User, $this(App\Models\User)> but returns Illuminate\Database\Eloquent\Relations\BelongsToMany<App\Models\BlockedUsers, $this(App\Models\User)>.

Check failure on line 209 in app/Models/User.php

View workflow job for this annotation

GitHub Actions / php 8.3 on ubuntu-22.04

Parameter #1 $related of method Illuminate\Database\Eloquent\Model::belongsToMany() expects class-string<Illuminate\Database\Eloquent\Model>, string given.

Check failure on line 209 in app/Models/User.php

View workflow job for this annotation

GitHub Actions / php 8.3 on ubuntu-22.04

Unable to resolve the template type TRelatedModel in call to method Illuminate\Database\Eloquent\Model::belongsToMany()
->as('blocked')
->withTimestamps();
}

/**
* Belongs To Many Bookmarks.
*
Expand Down
48 changes: 48 additions & 0 deletions app/Models/UserBlock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

namespace App\Models;

use App\Traits\Auditable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
* App\Models\UserAudible.
*
* @property int $id
* @property int $user_id
* @property int $blocked_user_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*/
class UserAudible extends Model
{
use Auditable;

/** @use HasFactory<\Database\Factories\BookmarkFactory> */
use HasFactory;

/**
* Belongs To A User.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class)->withTrashed();
}
}
41 changes: 41 additions & 0 deletions database/migrations/2024_11_06_083742_create_block_user_system.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_blocks', function (Blueprint $table): void {
$table->unsignedInteger('user_id');
$table->unsignedInteger('blocked_user_id');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_blocks');
}
};

0 comments on commit e44b861

Please sign in to comment.