Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb59af7f

Browse files
committed
Allow eloquent builder instance on BelongsTo model field.
1 parent056b6a8 commitb59af7f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎src/Html/Editor/Fields/BelongsTo.php‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
namespaceYajra\DataTables\Html\Editor\Fields;
44

55
useIlluminate\Support\Str;
6+
useIlluminate\Database\Eloquent\Builder;
67

78
class BelongsToextends Select
89
{
910
/**
10-
* @param string $class
11+
* @param string|Builder $class
1112
* @param string $text
1213
* @param string $id
1314
* @param string|null $foreign
1415
* @return \Yajra\DataTables\Html\Editor\Fields\Field|static
1516
*/
1617
publicstaticfunctionmodel($class,$text,$id ='id',$foreign =null)
1718
{
18-
$table = Str::singular(app($class)->getTable());
19+
if ($classinstanceof Builder) {
20+
$table =$class->getModel()->getTable();
21+
}else {
22+
$table =app($class)->getTable();
23+
}
24+
25+
$table = Str::singular($table);
1926
$foreign =$foreign ??$table .'_id';
2027

2128
returnself::make($foreign, Str::title($table))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp