Skip to content

Instantly share code, notes, and snippets.

@billydekid
Last active April 17, 2024 11:26
Show Gist options
  • Select an option

  • Save billydekid/70d4f2851a1d6ff05cbccd395f925cc0 to your computer and use it in GitHub Desktop.

Select an option

Save billydekid/70d4f2851a1d6ff05cbccd395f925cc0 to your computer and use it in GitHub Desktop.
How to get $workflow_type_id
<?php
class ProjectResource extends Resource
{
protected static ?string $model = Project::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
/**
* File upload dynamic
*
**/
public static function Files(): Array
{
// bgm mendapatkan value $get('workflow_type_id) yg berasal Select form?
$wftid = DB::table('doument_type_workflow_type')->where('workflow_type_id', $get('workflow_type_id'));
// return a schema array
return [
//
];
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('project_name')
->required()
->maxLength(64),
Forms\Components\TextInput::make('project_code')
->required()
->disabledOn('edit')
->maxLength(64),
Forms\Components\Select::make('workflow_type_id')
->relationship(name: 'workflowType', titleAttribute: 'workflow_name')
->disabledOn('edit')
->live()
->required(),
Forms\Components\Section::make('Document(s) required')
->visible(fn (Get $get): bool => is_numeric($get('workflow_type_id')))
->description('Type of docs required for this project')
->schema(
// ...
self::Files(),
),
Forms\Components\DatePicker::make('due_date')
->required(),
Forms\Components\Textarea::make('note')
->columnSpanFull(),
]);
}
//
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment