Commit c110d762 authored by Jens Segers's avatar Jens Segers

Small BelongsToMany tweak

parent 040b7944
...@@ -221,12 +221,13 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model { ...@@ -221,12 +221,13 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
$instance = new $related; $instance = new $related;
$otherKey = $otherKey ?: $instance->getForeignKey() . 's'; $otherKey = $otherKey ?: $instance->getForeignKey() . 's';
// If no table name was provided, we can guess it by concatenating the two // If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names // models using underscores in alphabetical order. The two model names
// are transformed to snake case from their default CamelCase also. // are transformed to snake case from their default CamelCase also.
if (is_null($collection)) if (is_null($collection))
{ {
$collection = snake_case(str_plural(class_basename($related))); $collection = $instance->getTable();
} }
// Now we're ready to create a new query builder for the related model and // Now we're ready to create a new query builder for the related model and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment