Skip to content

Commit

Permalink
Merge pull request #76 from canyongbs/feature/ASSIST-289-interactions
Browse files Browse the repository at this point in the history
[ASSIST-289] Add ability to log interactions
  • Loading branch information
Orrison authored Sep 13, 2023
2 parents f9bc22b + 66299ea commit e159ccc
Show file tree
Hide file tree
Showing 136 changed files with 3,867 additions and 430 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Assist\AssistDataModel\Models\Student;
use Filament\Resources\RelationManagers\RelationGroup;
use Assist\Alert\Filament\RelationManagers\AlertsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\Pages;
use Assist\Task\Filament\Resources\TaskResource\RelationManagers\TasksRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\EngagementsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\InteractionsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\SubscriptionsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\EngagementFilesRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\EngagementResponsesRelationManager;
Expand All @@ -33,11 +35,14 @@ public static function form(Form $form): Form
public static function getRelations(): array
{
return [
RelationGroup::make('Engagement', [
EngagementsRelationManager::class,
EngagementResponsesRelationManager::class,
EngagementFilesRelationManager::class,
]),
SubscriptionsRelationManager::class,
EngagementsRelationManager::class,
EngagementResponsesRelationManager::class,
EngagementFilesRelationManager::class,
TasksRelationManager::class,
InteractionsRelationManager::class,
AlertsRelationManager::class,
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers;

use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Infolists\Infolist;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Component;
use Assist\AssistDataModel\Models\Student;
use Filament\Forms\Components\MorphToSelect;
use App\Filament\Resources\RelationManagers\RelationManager;
use Assist\Interaction\Filament\Resources\InteractionResource\Pages\CreateInteraction;
use Assist\Interaction\Filament\Resources\InteractionResource\RelationManagers\HasManyMorphedInteractionsRelationManager;

class InteractionsRelationManager extends RelationManager
{
protected static string $relationship = 'interactions';

public function form(Form $form): Form
{
$createInteractionForm = (resolve(CreateInteraction::class))->form($form);

$formComponents = collect($createInteractionForm->getComponents())->filter(function (Component $component) {
if (! $component instanceof MorphToSelect) {
return true;
}
})->toArray();

return parent::form($createInteractionForm)
->schema([
Hidden::make('interactable_id')
->default($this->ownerRecord->identifier()),
Hidden::make('interactable_type')
->default(resolve(Student::class)->getMorphClass()),
...$formComponents,
]);
}

public function infolist(Infolist $infolist): Infolist
{
return (resolve(HasManyMorphedInteractionsRelationManager::class))->infolist($infolist);
}

public function table(Table $table): Table
{
return (resolve(HasManyMorphedInteractionsRelationManager::class))->table($table);
}
}
7 changes: 5 additions & 2 deletions app-modules/assist-data-model/src/Models/Student.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
use Assist\AssistDataModel\Models\Contracts\Identifiable;
use Assist\Authorization\Models\Concerns\DefinesPermissions;
use Illuminate\Notifications\DatabaseNotificationCollection;
use Assist\AssistDataModel\Database\Factories\StudentFactory;
use Assist\Audit\Models\Concerns\Auditable as AuditableTrait;
use Assist\Engagement\Models\Concerns\HasManyMorphedEngagements;
use Assist\Interaction\Models\Concerns\HasManyMorphedInteractions;
use Assist\Engagement\Models\Concerns\HasManyMorphedEngagementResponses;

/**
Expand All @@ -43,6 +43,8 @@
* @property-read int|null $engagement_responses_count
* @property-read Collection<int, Engagement> $engagements
* @property-read int|null $engagements_count
* @property-read Collection<int, \Assist\Interaction\Models\Interaction> $interactions
* @property-read int|null $interactions_count
* @property-read DatabaseNotificationCollection<int, DatabaseNotification> $notifications
* @property-read int|null $notifications_count
* @property-read Collection<int, ServiceRequest> $serviceRequests
Expand All @@ -52,7 +54,7 @@
* @property-read Collection<int, Task> $tasks
* @property-read int|null $tasks_count
*
* @method static StudentFactory factory($count = null, $state = [])
* @method static \Assist\AssistDataModel\Database\Factories\StudentFactory factory($count = null, $state = [])
* @method static Builder|Student newModelQuery()
* @method static Builder|Student newQuery()
* @method static Builder|Student query()
Expand All @@ -67,6 +69,7 @@ class Student extends Model implements Auditable, Subscribable, Identifiable
use Notifiable;
use HasManyMorphedEngagements;
use HasManyMorphedEngagementResponses;
use HasManyMorphedInteractions;

protected $primaryKey = 'sisid';

Expand Down
2 changes: 1 addition & 1 deletion app-modules/engagement/src/Models/Engagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @property string|null $engagement_batch_id
* @property string|null $recipient_id
* @property string|null $recipient_type
* @property string $subject
* @property string|null $subject
* @property string|null $body
* @property string $deliver_at
* @property Carbon|null $created_at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function boot()
$schedule->job(DeliverEngagements::class)->everyMinute();
});

$this->observers();
$this->registerObservers();
}

public function observers(): void
public function registerObservers(): void
{
EngagementFileEntities::observe(EngagementFileEntitiesObserver::class);
Engagement::observe(EngagementObserver::class);
Expand Down
26 changes: 26 additions & 0 deletions app-modules/interaction/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "canyon-gbs/interaction",
"description": "",
"type": "library",
"version": "1.0",
"license": "proprietary",
"require": {
"filament/filament": "^3.0.0"
},
"autoload": {
"psr-4": {
"Assist\\Interaction\\": "src/",
"Assist\\Interaction\\Tests\\": "tests/",
"Assist\\Interaction\\Database\\Factories\\": "database/factories/",
"Assist\\Interaction\\Database\\Seeders\\": "database/seeders/"
}
},
"minimum-stability": "dev",
"extra": {
"laravel": {
"providers": [
"Assist\\Interaction\\Providers\\InteractionServiceProvider"
]
}
}
}
3 changes: 3 additions & 0 deletions app-modules/interaction/config/permissions/api/custom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return [];
3 changes: 3 additions & 0 deletions app-modules/interaction/config/permissions/web/custom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionCampaign>
*/
class InteractionCampaignFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionDriver>
*/
class InteractionDriverFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
50 changes: 50 additions & 0 deletions app-modules/interaction/database/factories/InteractionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Assist\Interaction\Database\Factories;

use App\Models\User;
use Assist\Prospect\Models\Prospect;
use Assist\AssistDataModel\Models\Student;
use Assist\Interaction\Models\InteractionType;
use Assist\Interaction\Models\InteractionDriver;
use Assist\Interaction\Models\InteractionStatus;
use Assist\Interaction\Models\InteractionOutcome;
use Assist\Interaction\Models\InteractionCampaign;
use Assist\Interaction\Models\InteractionRelation;
use Assist\ServiceManagement\Models\ServiceRequest;
use Illuminate\Database\Eloquent\Factories\Factory;
use Assist\Interaction\Models\InteractionInstitution;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\Interaction>
*/
class InteractionFactory extends Factory
{
public function definition(): array
{
$interactable = fake()->randomElement([
Student::class,
Prospect::class,
ServiceRequest::class,
]);

$interactable = $interactable::factory()->create();

return [
'user_id' => User::factory(),
'interactable_id' => $interactable->identifier(),
'interactable_type' => $interactable->getMorphClass(),
'interaction_type_id' => InteractionType::factory(),
'interaction_relation_id' => InteractionRelation::factory(),
'interaction_campaign_id' => InteractionCampaign::factory(),
'interaction_driver_id' => InteractionDriver::factory(),
'interaction_status_id' => InteractionStatus::factory(),
'interaction_outcome_id' => InteractionOutcome::factory(),
'interaction_institution_id' => InteractionInstitution::factory(),
'start_datetime' => now(),
'end_datetime' => now()->addMinutes(5),
'subject' => fake()->sentence(),
'description' => fake()->paragraph(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionInstitution>
*/
class InteractionInstitutionFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionOutcome>
*/
class InteractionOutcomeFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionRelation>
*/
class InteractionRelationFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Assist\ServiceManagement\Enums\ColumnColorOptions;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionStatus>
*/
class InteractionStatusFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
'color' => $this->faker->randomElement(ColumnColorOptions::cases())->value,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionType>
*/
class InteractionTypeFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

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

return new class () extends Migration {
public function up(): void
{
Schema::create('interaction_types', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
};
Loading

0 comments on commit e159ccc

Please sign in to comment.