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