Skip to content

Commit

Permalink
Added User Invitation created_by and created_from columns..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jul 5, 2023
1 parent 2469bc2 commit 7d906b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/Jobs/Auth/CreateInvitation.php
Expand Up @@ -5,12 +5,15 @@
use App\Abstracts\Job;
use App\Models\Auth\UserInvitation;
use App\Notifications\Auth\Invitation as Notification;
use App\Traits\Sources;
use Exception;
use Illuminate\Support\Str;
use Symfony\Component\Mailer\Exception\TransportException;

class CreateInvitation extends Job
{
use Sources;

protected $invitation;

protected $user;
Expand All @@ -32,6 +35,8 @@ public function handle(): UserInvitation
$this->invitation = UserInvitation::create([
'user_id' => $this->user->id,
'token' => (string) Str::uuid(),
'created_by' => user_id(),
'created_from' => $this->getSourceName(request()),
]);

$notification = new Notification($this->invitation);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Auth/UserInvitation.php
Expand Up @@ -20,7 +20,7 @@ class UserInvitation extends Model
*
* @var string[]
*/
protected $fillable = ['user_id', 'token'];
protected $fillable = ['user_id', 'token', 'created_from', 'created_by'];

public function user()
{
Expand Down
12 changes: 12 additions & 0 deletions database/migrations/2023_06_22_000000_core_v3016.php
Expand Up @@ -26,6 +26,12 @@ public function up()

$table->unique(['company_id', 'key', 'deleted_at']);
});

// User Invitations
Schema::table('user_invitations', function (Blueprint $table) {
$table->unsignedInteger('created_by')->nullable()->after('token');
$table->string('created_from', 100)->nullable()->after('token');
});
}

/**
Expand All @@ -48,5 +54,11 @@ public function down()

$table->unique(['company_id', 'key']);
});

// User Invitations
Schema::table('user_invitations', function (Blueprint $table) {
$table->dropColumn('created_by');
$table->dropColumn('created_from');
});
}
};

0 comments on commit 7d906b7

Please sign in to comment.