Skip to content

Commit 353189b

Browse files
author
David Nahodyl
committed
minor organization, swapped layout/table retrieval order when getting table
1 parent 1fbcd6d commit 353189b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/Database/Eloquent/FMModel.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ abstract class FMModel extends Model
6868

6969
public function __construct(array $attributes = [])
7070
{
71-
// FileMaker users tables, but the connections use layouts, so we'll use that as a standard
72-
$this->setTable($this->layout ?? $this->table);
71+
// Laravel uses tables normally, but FileMaker users layouts, so we'll let users set either one for clarity
72+
// Set table if the user didn't set it and set $layout instead
73+
if (!$this->table){
74+
$this->setTable($this->layout);
75+
}
7376
parent::__construct($attributes);
7477
}
7578

@@ -408,7 +411,7 @@ public function getContainersToWrite(){
408411
*/
409412
public function getTable()
410413
{
411-
return $this->layout ?? $this->table ?? Str::snake(Str::pluralStudly(class_basename($this)));
414+
return $this->table ?? $this->layout ?? Str::snake(Str::pluralStudly(class_basename($this)));
412415
}
413416

414417
/**
@@ -478,4 +481,17 @@ public function setAttribute($key, $value)
478481
}
479482

480483

484+
/**
485+
* Qualify the given column name by the model's table.
486+
*
487+
* @param string $column
488+
* @return string
489+
*/
490+
public function qualifyColumn($column)
491+
{
492+
// we shouldn't ever qualify columns because they could be related data
493+
// so just return without the table
494+
return $column;
495+
}
496+
481497
}

0 commit comments

Comments
 (0)