feat: Change MediaMonitoring to HasOne relationship, restrict media_monitoring_id selection in the form to unique entries, and add sub-location and sub-classification columns to the table.
This commit is contained in:
parent
f159bea411
commit
f041ed98e7
@ -21,11 +21,14 @@ public static function configure(Schema $schema): Schema
|
||||
Section::make([
|
||||
Select::make('media_monitoring_id')
|
||||
->label('Monitoring Media')
|
||||
->relationship('mediaMonitoring', 'title')
|
||||
->relationship(
|
||||
'mediaMonitoring',
|
||||
'title',
|
||||
fn (Builder $query): Builder => $query->whereDoesntHave('issueManagement')
|
||||
)
|
||||
->searchable()
|
||||
->preload()
|
||||
->required()
|
||||
->autocomplete(false)
|
||||
->autofocus(),
|
||||
|
||||
Grid::make(2)
|
||||
@ -39,20 +42,19 @@ public static function configure(Schema $schema): Schema
|
||||
->afterStateUpdated(function (Set $set): void {
|
||||
$set('sub_location_id', null);
|
||||
})
|
||||
->required()
|
||||
->autocomplete(false),
|
||||
->required(),
|
||||
|
||||
Select::make('sub_location_id')
|
||||
->label('Sub Lokus')
|
||||
->relationship('subLocation', 'name', fn (Builder $query, Get $get): Builder => $query->where('location_id', $get('location_id')))
|
||||
->searchable()
|
||||
->preload()
|
||||
->required()
|
||||
->autocomplete(false),
|
||||
->required(),
|
||||
]),
|
||||
|
||||
RichEditor::make('description')
|
||||
->label('Keterangan')
|
||||
->placeholder('...')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
])->columnSpan(2),
|
||||
@ -63,16 +65,14 @@ public static function configure(Schema $schema): Schema
|
||||
->options(IssueSentiment::options())
|
||||
->required()
|
||||
->native(false)
|
||||
->in(implode(',', array_column(IssueSentiment::cases(), 'value')))
|
||||
->autocomplete(false),
|
||||
->in(implode(',', array_column(IssueSentiment::cases(), 'value'))),
|
||||
|
||||
Select::make('response')
|
||||
->label('Respon')
|
||||
->options(IssueSentiment::options())
|
||||
->required()
|
||||
->native(false)
|
||||
->in(implode(',', array_column(IssueSentiment::cases(), 'value')))
|
||||
->autocomplete(false),
|
||||
->in(implode(',', array_column(IssueSentiment::cases(), 'value'))),
|
||||
|
||||
Select::make('classification_id')
|
||||
->label('Klasifikasi')
|
||||
@ -83,16 +83,14 @@ public static function configure(Schema $schema): Schema
|
||||
->afterStateUpdated(function (Set $set): void {
|
||||
$set('sub_classification_id', null);
|
||||
})
|
||||
->required()
|
||||
->autocomplete(false),
|
||||
->required(),
|
||||
|
||||
Select::make('sub_classification_id')
|
||||
->label('Sub Klasifikasi')
|
||||
->relationship('subClassification', 'name', fn (Builder $query, Get $get): Builder => $query->where('classification_id', $get('classification_id'))->active())
|
||||
->searchable()
|
||||
->preload()
|
||||
->required()
|
||||
->autocomplete(false),
|
||||
->required(),
|
||||
])->columnSpan(1),
|
||||
])
|
||||
->columns(3);
|
||||
|
||||
@ -45,11 +45,21 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('subLocation.name')
|
||||
->label('Sub Lokus')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('classification.name')
|
||||
->label('Klasifikasi')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('subClassification.name')
|
||||
->label('Sub Klasifikasi')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@ -17,9 +18,9 @@ class MediaMonitoring extends Model implements HasMedia
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function issueManagements(): HasMany
|
||||
public function issueManagement(): HasOne
|
||||
{
|
||||
return $this->hasMany(IssueManagement::class);
|
||||
return $this->hasOne(IssueManagement::class);
|
||||
}
|
||||
|
||||
public function mediaMonitoringThemes(): HasMany
|
||||
|
||||
Loading…
Reference in New Issue
Block a user