File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 33namespace Yajra \DataTables \Html \Editor \Fields ;
44
55use Illuminate \Support \Str ;
6+ use Illuminate \Database \Eloquent \Builder ;
67
78class BelongsTo extends 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 public static function model ($ class , $ text , $ id = 'id ' , $ foreign = null )
1718 {
18- $ table = Str::singular (app ($ class )->getTable ());
19+ if ($ class instanceof 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 return self ::make ($ foreign , Str::title ($ table ))
You can’t perform that action at this time.
0 commit comments