File tree Expand file tree Collapse file tree 6 files changed +27
-8
lines changed Expand file tree Collapse file tree 6 files changed +27
-8
lines changed Original file line number Diff line number Diff line change 130
130
'references-nullable ' => true ,
131
131
/*
132
132
* Ether you define your models for references or customize the view.
133
+ * Example: [App/Models/User::class]
133
134
*/
134
135
'reference-models ' => []
135
136
];
Original file line number Diff line number Diff line change 47
47
@if (! $model -> hasReferenceAccess () )
48
48
@continue
49
49
@endif
50
- <option value =" {{ $model -> toReference () } }"
51
- @if (old (' reference' ) === $model -> toReference () )
52
- selected
53
- @endif >@lang (basename (get_class ($model )) ) #{{ $model -> id } } </option >
50
+ <option
51
+ value =" {{ $modelReference = \RexlManu \LaravelTickets \Helper \ReferenceHelper:: modelToReference ($model ) } }"
52
+ @if (old (' reference' ) === $modelReference )
53
+ selected
54
+ @endif >{{ $model -> toReference () } } </option >
54
55
@endforeach
55
56
@endforeach
56
57
</select >
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
92
92
<label >@lang (' Reference' ):</label >
93
93
@php ($referenceable = $ticket -> reference -> referenceable )
94
94
<input class =" form-control" type =" text"
95
- value =" @lang ( basename ( get_class ( $referenceable )) ) # {{ $referenceable -> id } }" disabled >
95
+ value =" {{ $referenceable -> toReference () } }" disabled >
96
96
</div >
97
97
@endif
98
98
<div class =" form-group" >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace RexlManu \LaravelTickets \Helper ;
5
+
6
+
7
+ class ReferenceHelper
8
+ {
9
+
10
+ public static function modelToReference ($ model ) : string
11
+ {
12
+ $ type = get_class ($ model );
13
+ return "$ type, $ model ->id " ;
14
+ }
15
+
16
+
17
+ }
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ interface TicketReference
15
15
function hasReferenceAccess () : bool ;
16
16
17
17
/**
18
- * Combine type and id to a string for forms
18
+ * Show the name when on selection
19
19
*
20
20
* @return string
21
21
*/
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ trait HasTicketReference
9
9
10
10
public function toReference () : string
11
11
{
12
- $ type = get_class ($ this );
13
- return "$ type, $ this ->id " ;
12
+ $ type = basename ( get_class ($ this ) );
13
+ return "$ type # $ this ->id " ;
14
14
}
15
15
16
16
}
You can’t perform that action at this time.
0 commit comments