grammar.php 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php namespace Laravel\Database\Schema\Grammars;
  2. use Laravel\Fluent;
  3. use Laravel\Database\Schema\Table;
  4. abstract class Grammar extends \Laravel\Database\Grammar {
  5. /**
  6. * Get the appropriate data type definition for the column.
  7. *
  8. * @param Fluent $column
  9. * @return string
  10. */
  11. protected function type(Fluent $column)
  12. {
  13. return $this->{'type_'.$column->type}($column);
  14. }
  15. /**
  16. * Wrap a value in keyword identifiers.
  17. *
  18. * @param Table|string $value
  19. * @return string
  20. */
  21. public function wrap($value)
  22. {
  23. // This method is primarily for convenience so we can just pass a
  24. // column or table instance into the wrap method without sending
  25. // in the name each time we need to wrap one of these objects.
  26. if ($value instanceof Table)
  27. {
  28. return $this->wrap_table($value->name);
  29. }
  30. elseif ($value instanceof Fluent)
  31. {
  32. $value = $value->name;
  33. }
  34. return parent::wrap($value);
  35. }
  36. }