repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/PointType.php | src/Database/Types/Mysql/PointType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class PointType extends Type
{
public const NAME = 'point';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'point';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/GeometryCollectionType.php | src/Database/Types/Mysql/GeometryCollectionType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class GeometryCollectionType extends Type
{
public const NAME = 'geometrycollection';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'geometrycollection';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/GeometryType.php | src/Database/Types/Mysql/GeometryType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class GeometryType extends Type
{
public const NAME = 'geometry';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'geometry';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/PolygonType.php | src/Database/Types/Mysql/PolygonType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class PolygonType extends Type
{
public const NAME = 'polygon';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'polygon';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/LongBlobType.php | src/Database/Types/Mysql/LongBlobType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class LongBlobType extends Type
{
public const NAME = 'longblob';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'longblob';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/LineStringType.php | src/Database/Types/Mysql/LineStringType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class LineStringType extends Type
{
public const NAME = 'linestring';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'linestring';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/MultiLineStringType.php | src/Database/Types/Mysql/MultiLineStringType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class MultiLineStringType extends Type
{
public const NAME = 'multilinestring';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'multilinestring';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/VarBinaryType.php | src/Database/Types/Mysql/VarBinaryType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class VarBinaryType extends Type
{
public const NAME = 'varbinary';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
$field['length'] = empty($field['length']) ? 255 : $field['length'];
return "varbinary({$field['length']})";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/SetType.php | src/Database/Types/Mysql/SetType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Illuminate\Support\Facades\DB;
use TCG\Voyager\Database\Types\Type;
class SetType extends Type
{
public const NAME = 'set';
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
throw new \Exception('Set type is not supported');
// we're going to store SET values in the comment since DBAL doesn't support
$allowed = explode(',', trim($fieldDeclaration['comment']));
$pdo = DB::connection()->getPdo();
// trim the values
$fieldDeclaration['allowed'] = array_map(function ($value) use ($pdo) {
return $pdo->quote(trim($value));
}, $allowed);
return 'set('.implode(', ', $field['allowed']).')';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/FloatType.php | src/Database/Types/Mysql/FloatType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class FloatType extends Type
{
public const NAME = 'float';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'float';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/TimeStampType.php | src/Database/Types/Mysql/TimeStampType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TimeStampType extends Type
{
public const NAME = 'timestamp';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
if (isset($field['default'])) {
return 'timestamp';
}
return 'timestamp null';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/YearType.php | src/Database/Types/Mysql/YearType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class YearType extends Type
{
public const NAME = 'year';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'year';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/MultiPolygonType.php | src/Database/Types/Mysql/MultiPolygonType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class MultiPolygonType extends Type
{
public const NAME = 'multipolygon';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'multipolygon';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Mysql/BinaryType.php | src/Database/Types/Mysql/BinaryType.php | <?php
namespace TCG\Voyager\Database\Types\Mysql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class BinaryType extends Type
{
public const NAME = 'binary';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
$field['length'] = empty($field['length']) ? 255 : $field['length'];
return "binary({$field['length']})";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Common/CharType.php | src/Database/Types/Common/CharType.php | <?php
namespace TCG\Voyager\Database\Types\Common;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class CharType extends Type
{
public const NAME = 'char';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
$field['length'] = empty($field['length']) ? 1 : $field['length'];
return "char({$field['length']})";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Common/DoubleType.php | src/Database/Types/Common/DoubleType.php | <?php
namespace TCG\Voyager\Database\Types\Common;
use Doctrine\DBAL\Types\FloatType as DoctrineFloatType;
class DoubleType extends DoctrineFloatType
{
public const NAME = 'double';
public function getName()
{
return static::NAME;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Common/VarCharType.php | src/Database/Types/Common/VarCharType.php | <?php
namespace TCG\Voyager\Database\Types\Common;
use Doctrine\DBAL\Types\StringType as DoctrineStringType;
class VarCharType extends DoctrineStringType
{
public const NAME = 'varchar';
public function getName()
{
return static::NAME;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Common/JsonType.php | src/Database/Types/Common/JsonType.php | <?php
namespace TCG\Voyager\Database\Types\Common;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class JsonType extends Type
{
public const NAME = 'json';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'json';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Common/NumericType.php | src/Database/Types/Common/NumericType.php | <?php
namespace TCG\Voyager\Database\Types\Common;
use Doctrine\DBAL\Types\DecimalType as DoctrineDecimalType;
class NumericType extends DoctrineDecimalType
{
public const NAME = 'numeric';
public function getName()
{
return static::NAME;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Common/TextType.php | src/Database/Types/Common/TextType.php | <?php
namespace TCG\Voyager\Database\Types\Common;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TextType extends Type
{
public const NAME = 'text';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'text';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/JsonbType.php | src/Database/Types/Postgresql/JsonbType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class JsonbType extends Type
{
public const NAME = 'jsonb';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'jsonb';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/MoneyType.php | src/Database/Types/Postgresql/MoneyType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class MoneyType extends Type
{
public const NAME = 'money';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'money';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/UuidType.php | src/Database/Types/Postgresql/UuidType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class UuidType extends Type
{
public const NAME = 'uuid';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'uuid';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/SmallIntType.php | src/Database/Types/Postgresql/SmallIntType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class SmallIntType extends Type
{
public const NAME = 'smallint';
public const DBTYPE = 'int2';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
$commonIntegerTypeDeclaration = call_protected_method($platform, '_getCommonIntegerTypeDeclarationSQL', $field);
$type = $field['autoincrement'] ? 'smallserial' : 'smallint';
return $type.$commonIntegerTypeDeclaration;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/CharacterVaryingType.php | src/Database/Types/Postgresql/CharacterVaryingType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use TCG\Voyager\Database\Types\Common\VarCharType;
class CharacterVaryingType extends VarCharType
{
public const NAME = 'character varying';
public const DBTYPE = 'varchar';
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/BitType.php | src/Database/Types/Postgresql/BitType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class BitType extends Type
{
public const NAME = 'bit';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
$length = empty($field['length']) ? 1 : $field['length'];
return "bit({$length})";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/TxidSnapshotType.php | src/Database/Types/Postgresql/TxidSnapshotType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TxidSnapshotType extends Type
{
public const NAME = 'txid_snapshot';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'txid_snapshot';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/GeometryType.php | src/Database/Types/Postgresql/GeometryType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class GeometryType extends Type
{
public const NAME = 'geometry';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'geometry';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/TsQueryType.php | src/Database/Types/Postgresql/TsQueryType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TsQueryType extends Type
{
public const NAME = 'tsquery';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'tsquery';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/XmlType.php | src/Database/Types/Postgresql/XmlType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class XmlType extends Type
{
public const NAME = 'xml';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'xml';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/CharacterType.php | src/Database/Types/Postgresql/CharacterType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use TCG\Voyager\Database\Types\Common\CharType;
class CharacterType extends CharType
{
public const NAME = 'character';
public const DBTYPE = 'bpchar';
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/TimeStampTzType.php | src/Database/Types/Postgresql/TimeStampTzType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TimeStampTzType extends Type
{
public const NAME = 'timestamptz';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'timestamp(0) with time zone';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/ByteaType.php | src/Database/Types/Postgresql/ByteaType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class ByteaType extends Type
{
public const NAME = 'bytea';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'bytea';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/MacAddrType.php | src/Database/Types/Postgresql/MacAddrType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class MacAddrType extends Type
{
public const NAME = 'macaddr';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'macaddr';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/TimeTzType.php | src/Database/Types/Postgresql/TimeTzType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TimeTzType extends Type
{
public const NAME = 'timetz';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'time(0) with time zone';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/InetType.php | src/Database/Types/Postgresql/InetType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class InetType extends Type
{
public const NAME = 'inet';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'inet';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/TsVectorType.php | src/Database/Types/Postgresql/TsVectorType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TsVectorType extends Type
{
public const NAME = 'tsvector';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'tsvector';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/IntervalType.php | src/Database/Types/Postgresql/IntervalType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class IntervalType extends Type
{
public const NAME = 'interval';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'interval';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/CidrType.php | src/Database/Types/Postgresql/CidrType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class CidrType extends Type
{
public const NAME = 'cidr';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'cidr';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/TimeStampType.php | src/Database/Types/Postgresql/TimeStampType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class TimeStampType extends Type
{
public const NAME = 'timestamp';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'timestamp(0) without time zone';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/DoublePrecisionType.php | src/Database/Types/Postgresql/DoublePrecisionType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use TCG\Voyager\Database\Types\Common\DoubleType;
class DoublePrecisionType extends DoubleType
{
public const NAME = 'double precision';
public const DBTYPE = 'float8';
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/BitVaryingType.php | src/Database/Types/Postgresql/BitVaryingType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class BitVaryingType extends Type
{
public const NAME = 'bit varying';
public const DBTYPE = 'varbit';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
$length = empty($field['length']) ? 255 : $field['length'];
return "varbit({$length})";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Postgresql/RealType.php | src/Database/Types/Postgresql/RealType.php | <?php
namespace TCG\Voyager\Database\Types\Postgresql;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class RealType extends Type
{
public const NAME = 'real';
public const DBTYPE = 'float4';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'real';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Types/Sqlite/RealType.php | src/Database/Types/Sqlite/RealType.php | <?php
namespace TCG\Voyager\Database\Types\Sqlite;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use TCG\Voyager\Database\Types\Type;
class RealType extends Type
{
public const NAME = 'real';
public function getSQLDeclaration(array $field, AbstractPlatform $platform)
{
return 'real';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Schema/Table.php | src/Database/Schema/Table.php | <?php
namespace TCG\Voyager\Database\Schema;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table as DoctrineTable;
class Table extends DoctrineTable
{
public static function make($table)
{
if (!is_array($table)) {
$table = json_decode($table, true);
}
$name = Identifier::validate($table['name'], 'Table');
$columns = [];
foreach ($table['columns'] as $columnArr) {
$column = Column::make($columnArr, $table['name']);
$columns[$column->getName()] = $column;
}
$indexes = [];
foreach ($table['indexes'] as $indexArr) {
$index = Index::make($indexArr);
$indexes[$index->getName()] = $index;
}
$foreignKeys = [];
foreach ($table['foreignKeys'] as $foreignKeyArr) {
$foreignKey = ForeignKey::make($foreignKeyArr);
$foreignKeys[$foreignKey->getName()] = $foreignKey;
}
$options = $table['options'];
return new self($name, $columns, $indexes, [], $foreignKeys, $options);
}
public function getColumnsIndexes($columns, $sort = false)
{
if (!is_array($columns)) {
$columns = [$columns];
}
$matched = [];
foreach ($this->_indexes as $index) {
if ($index->spansColumns($columns)) {
$matched[$index->getName()] = $index;
}
}
if (count($matched) > 1 && $sort) {
// Sort indexes based on priority: PRI > UNI > IND
uasort($matched, function ($index1, $index2) {
$index1_type = Index::getType($index1);
$index2_type = Index::getType($index2);
if ($index1_type == $index2_type) {
return 0;
}
if ($index1_type == Index::PRIMARY) {
return -1;
}
if ($index2_type == Index::PRIMARY) {
return 1;
}
if ($index1_type == Index::UNIQUE) {
return -1;
}
// If we reach here, it means: $index1=INDEX && $index2=UNIQUE
return 1;
});
}
return $matched;
}
public function diff(DoctrineTable $compareTable)
{
return (new Comparator())->diffTable($this, $compareTable);
}
public function diffOriginal()
{
return (new Comparator())->diffTable(SchemaManager::getDoctrineTable($this->_name), $this);
}
/**
* @return array
*/
public function toArray()
{
return [
'name' => $this->_name,
'oldName' => $this->_name,
'columns' => $this->exportColumnsToArray(),
'indexes' => $this->exportIndexesToArray(),
'primaryKeyName' => $this->_primaryKeyName,
'foreignKeys' => $this->exportForeignKeysToArray(),
'options' => $this->_options,
];
}
/**
* @return string
*/
public function toJson()
{
return json_encode($this->toArray());
}
/**
* @return array
*/
public function exportColumnsToArray()
{
$exportedColumns = [];
foreach ($this->getColumns() as $name => $column) {
$exportedColumns[] = Column::toArray($column);
}
return $exportedColumns;
}
/**
* @return array
*/
public function exportIndexesToArray()
{
$exportedIndexes = [];
foreach ($this->getIndexes() as $name => $index) {
$indexArr = Index::toArray($index);
$indexArr['table'] = $this->_name;
$exportedIndexes[] = $indexArr;
}
return $exportedIndexes;
}
/**
* @return array
*/
public function exportForeignKeysToArray()
{
$exportedForeignKeys = [];
foreach ($this->getForeignKeys() as $name => $fk) {
$exportedForeignKeys[$name] = ForeignKey::toArray($fk);
}
return $exportedForeignKeys;
}
public function __get($property)
{
$getter = 'get'.ucfirst($property);
if (!method_exists($this, $getter)) {
throw new \Exception("Property {$property} doesn't exist or is unavailable");
}
return $this->$getter();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Schema/ForeignKey.php | src/Database/Schema/ForeignKey.php | <?php
namespace TCG\Voyager\Database\Schema;
use Doctrine\DBAL\Schema\ForeignKeyConstraint as DoctrineForeignKey;
abstract class ForeignKey
{
public static function make(array $foreignKey)
{
// Set the local table
$localTable = null;
if (isset($foreignKey['localTable'])) {
$localTable = SchemaManager::getDoctrineTable($foreignKey['localTable']);
}
$localColumns = $foreignKey['localColumns'];
$foreignTable = $foreignKey['foreignTable'];
$foreignColumns = $foreignKey['foreignColumns'];
$options = $foreignKey['options'] ?? [];
// Set the name
$name = isset($foreignKey['name']) ? trim($foreignKey['name']) : '';
if (empty($name)) {
$table = isset($localTable) ? $localTable->getName() : null;
$name = Index::createName($localColumns, 'foreign', $table);
} else {
$name = Identifier::validate($name, 'Foreign Key');
}
$doctrineForeignKey = new DoctrineForeignKey(
$localColumns,
$foreignTable,
$foreignColumns,
$name,
$options
);
if (isset($localTable)) {
$doctrineForeignKey->setLocalTable($localTable);
}
return $doctrineForeignKey;
}
/**
* @return array
*/
public static function toArray(DoctrineForeignKey $fk)
{
return [
'name' => $fk->getName(),
'localTable' => $fk->getLocalTableName(),
'localColumns' => $fk->getLocalColumns(),
'foreignTable' => $fk->getForeignTableName(),
'foreignColumns' => $fk->getForeignColumns(),
'options' => $fk->getOptions(),
];
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Schema/Identifier.php | src/Database/Schema/Identifier.php | <?php
namespace TCG\Voyager\Database\Schema;
use Illuminate\Support\Facades\Validator;
abstract class Identifier
{
// Warning: Do not modify this
public const REGEX = '^[a-zA-Z_][a-zA-Z0-9_]*$';
public static function validate($identifier, $asset = '')
{
$identifier = trim($identifier);
$validator = Validator::make(['identifier' => $identifier], [
'identifier' => 'required|regex:'.'/'.static::REGEX.'/',
]);
if ($validator->fails()) {
throw new \Exception("{$asset} Identifier {$identifier} is invalid");
}
return $identifier;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Schema/SchemaManager.php | src/Database/Schema/SchemaManager.php | <?php
namespace TCG\Voyager\Database\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Table as DoctrineTable;
use Illuminate\Support\Facades\DB;
use TCG\Voyager\Database\Types\Type;
abstract class SchemaManager
{
// todo: trim parameters
public static function __callStatic($method, $args)
{
return static::manager()->$method(...$args);
}
public static function manager()
{
return DB::connection()->getDoctrineSchemaManager();
}
public static function getDatabaseConnection()
{
return DB::connection()->getDoctrineConnection();
}
public static function tableExists($table)
{
if (!is_array($table)) {
$table = [$table];
}
return static::manager()->tablesExist($table);
}
public static function listTables()
{
$tables = [];
foreach (static::manager()->listTableNames() as $tableName) {
$tables[$tableName] = static::listTableDetails($tableName);
}
return $tables;
}
/**
* @param string $tableName
*
* @return \TCG\Voyager\Database\Schema\Table
*/
public static function listTableDetails($tableName)
{
$columns = static::manager()->listTableColumns($tableName);
$foreignKeys = [];
if (static::manager()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreignKeys = static::manager()->listTableForeignKeys($tableName);
}
$indexes = static::manager()->listTableIndexes($tableName);
return new Table($tableName, $columns, $indexes, [], $foreignKeys, []);
}
/**
* Describes given table.
*
* @param string $tableName
*
* @return \Illuminate\Support\Collection
*/
public static function describeTable($tableName)
{
Type::registerCustomPlatformTypes();
$table = static::listTableDetails($tableName);
return collect($table->columns)->map(function ($column) use ($table) {
$columnArr = Column::toArray($column);
$columnArr['field'] = $columnArr['name'];
$columnArr['type'] = $columnArr['type']['name'];
// Set the indexes and key
$columnArr['indexes'] = [];
$columnArr['key'] = null;
if ($columnArr['indexes'] = $table->getColumnsIndexes($columnArr['name'], true)) {
// Convert indexes to Array
foreach ($columnArr['indexes'] as $name => $index) {
$columnArr['indexes'][$name] = Index::toArray($index);
}
// If there are multiple indexes for the column
// the Key will be one with highest priority
$indexType = array_values($columnArr['indexes'])[0]['type'];
$columnArr['key'] = substr($indexType, 0, 3);
}
return $columnArr;
});
}
public static function listTableColumnNames($tableName)
{
Type::registerCustomPlatformTypes();
$columnNames = [];
foreach (static::manager()->listTableColumns($tableName) as $column) {
$columnNames[] = $column->getName();
}
return $columnNames;
}
public static function createTable($table)
{
if (!($table instanceof DoctrineTable)) {
$table = Table::make($table);
}
static::manager()->createTable($table);
}
public static function getDoctrineTable($table)
{
$table = trim($table);
if (!static::tableExists($table)) {
throw SchemaException::tableDoesNotExist($table);
}
return static::manager()->listTableDetails($table);
}
public static function getDoctrineColumn($table, $column)
{
return static::getDoctrineTable($table)->getColumn($column);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Schema/Column.php | src/Database/Schema/Column.php | <?php
namespace TCG\Voyager\Database\Schema;
use Doctrine\DBAL\Schema\Column as DoctrineColumn;
use Doctrine\DBAL\Types\Type as DoctrineType;
use TCG\Voyager\Database\Types\Type;
abstract class Column
{
public static function make(array $column, string $tableName = null)
{
$name = Identifier::validate($column['name'], 'Column');
$type = $column['type'];
$type = ($type instanceof DoctrineType) ? $type : DoctrineType::getType(trim($type['name']));
$type->tableName = $tableName;
$options = array_diff_key($column, array_flip(['name', 'composite', 'oldName', 'null', 'extra', 'type', 'charset', 'collation']));
return new DoctrineColumn($name, $type, $options);
}
/**
* @return array
*/
public static function toArray(DoctrineColumn $column)
{
$columnArr = $column->toArray();
$columnArr['type'] = Type::toArray($columnArr['type']);
$columnArr['oldName'] = $columnArr['name'];
$columnArr['null'] = $columnArr['notnull'] ? 'NO' : 'YES';
$columnArr['extra'] = static::getExtra($column);
$columnArr['composite'] = false;
return $columnArr;
}
/**
* @return string
*/
protected static function getExtra(DoctrineColumn $column)
{
$extra = '';
$extra .= $column->getAutoincrement() ? 'auto_increment' : '';
// todo: Add Extra stuff like mysql 'onUpdate' etc...
return $extra;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Schema/Index.php | src/Database/Schema/Index.php | <?php
namespace TCG\Voyager\Database\Schema;
use Doctrine\DBAL\Schema\Index as DoctrineIndex;
abstract class Index
{
public const PRIMARY = 'PRIMARY';
public const UNIQUE = 'UNIQUE';
public const INDEX = 'INDEX';
public static function make(array $index)
{
$columns = $index['columns'];
if (!is_array($columns)) {
$columns = [$columns];
}
if (isset($index['type'])) {
$type = $index['type'];
$isPrimary = ($type == static::PRIMARY);
$isUnique = $isPrimary || ($type == static::UNIQUE);
} else {
$isPrimary = $index['isPrimary'];
$isUnique = $index['isUnique'];
// Set the type
if ($isPrimary) {
$type = static::PRIMARY;
} elseif ($isUnique) {
$type = static::UNIQUE;
} else {
$type = static::INDEX;
}
}
// Set the name
$name = trim($index['name'] ?? '');
if (empty($name)) {
$table = $index['table'] ?? null;
$name = static::createName($columns, $type, $table);
} else {
$name = Identifier::validate($name, 'Index');
}
$flags = $index['flags'] ?? [];
$options = $index['options'] ?? [];
return new DoctrineIndex($name, $columns, $isUnique, $isPrimary, $flags, $options);
}
/**
* @return array
*/
public static function toArray(DoctrineIndex $index)
{
$name = $index->getName();
$columns = $index->getColumns();
return [
'name' => $name,
'oldName' => $name,
'columns' => $columns,
'type' => static::getType($index),
'isPrimary' => $index->isPrimary(),
'isUnique' => $index->isUnique(),
'isComposite' => count($columns) > 1,
'flags' => $index->getFlags(),
'options' => $index->getOptions(),
];
}
public static function getType(DoctrineIndex $index)
{
if ($index->isPrimary()) {
return static::PRIMARY;
} elseif ($index->isUnique()) {
return static::UNIQUE;
} else {
return static::INDEX;
}
}
/**
* Create a default index name.
*
* @param array $columns
* @param string $type
* @param string $table
*
* @return string
*/
public static function createName(array $columns, $type, $table = null)
{
$table = isset($table) ? trim($table).'_' : '';
$type = trim($type);
$name = strtolower($table.implode('_', $columns).'_'.$type);
return str_replace(['-', '.'], '_', $name);
}
public static function availableTypes()
{
return [
static::PRIMARY,
static::UNIQUE,
static::INDEX,
];
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Platforms/Platform.php | src/Database/Platforms/Platform.php | <?php
namespace TCG\Voyager\Database\Platforms;
use Illuminate\Support\Collection;
abstract class Platform
{
// abstract public static function getTypes(Collection $typeMapping);
// abstract public static function registerCustomTypeOptions();
public static function getPlatform($platformName)
{
$platform = __NAMESPACE__.'\\'.ucfirst($platformName);
if (!class_exists($platform)) {
throw new \Exception("Platform {$platformName} doesn't exist");
}
return $platform;
}
public static function getPlatformTypes($platformName, Collection $typeMapping)
{
$platform = static::getPlatform($platformName);
return $platform::getTypes($typeMapping);
}
public static function registerPlatformCustomTypeOptions($platformName)
{
$platform = static::getPlatform($platformName);
return $platform::registerCustomTypeOptions();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Platforms/Mysql.php | src/Database/Platforms/Mysql.php | <?php
namespace TCG\Voyager\Database\Platforms;
use Illuminate\Support\Collection;
use TCG\Voyager\Database\Types\Type;
abstract class Mysql extends Platform
{
public static function getTypes(Collection $typeMapping)
{
$typeMapping->forget([
'real', // same as double
'int', // same as integer
'string', // same as varchar
'numeric', // same as decimal
]);
return $typeMapping;
}
public static function registerCustomTypeOptions()
{
// Not supported
Type::registerCustomOption(Type::NOT_SUPPORTED, true, [
'enum',
'set',
]);
// Not support index
Type::registerCustomOption(Type::NOT_SUPPORT_INDEX, true, '*text');
Type::registerCustomOption(Type::NOT_SUPPORT_INDEX, true, '*blob');
// Disable Default for unsupported types
Type::registerCustomOption('default', [
'disabled' => true,
], '*text');
Type::registerCustomOption('default', [
'disabled' => true,
], '*blob');
Type::registerCustomOption('default', [
'disabled' => true,
], 'json');
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Platforms/Postgresql.php | src/Database/Platforms/Postgresql.php | <?php
namespace TCG\Voyager\Database\Platforms;
use Illuminate\Support\Collection;
abstract class Postgresql extends Platform
{
public static function getTypes(Collection $typeMapping)
{
// todo: need to create
// box, circle, line, lseg, path, pg_lsn, point, polygon
$typeMapping->forget([
'smallint',
'serial',
'serial4',
'int',
'integer',
'bigserial',
'serial8',
'bigint',
'decimal',
'float',
'real',
'double',
'double precision',
'boolean',
'_varchar',
'char',
'datetime',
'year',
]);
return $typeMapping;
}
public static function registerCustomTypeOptions()
{
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Database/Platforms/Sqlite.php | src/Database/Platforms/Sqlite.php | <?php
namespace TCG\Voyager\Database\Platforms;
use Illuminate\Support\Collection;
abstract class Sqlite extends Platform
{
public static function getTypes(Collection $typeMapping)
{
$typeMapping->forget([
'decimal',
'double',
]);
return $typeMapping->unique();
}
public static function registerCustomTypeOptions()
{
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Facades/Voyager.php | src/Facades/Voyager.php | <?php
namespace TCG\Voyager\Facades;
use Illuminate\Support\Facades\Facade;
class Voyager extends Facade
{
/**
* Get the registered name of the component.
*
* @method static string image($file, $default = '')
* @method static $this useModel($name, $object)
*
* @see \TCG\Voyager\Voyager
* @return string
*/
protected static function getFacadeAccessor()
{
return 'voyager';
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Alert/Components/TextComponent.php | src/Alert/Components/TextComponent.php | <?php
namespace TCG\Voyager\Alert\Components;
class TextComponent extends AbstractComponent
{
protected $text;
public function create($text)
{
$this->text = $text;
}
public function render()
{
return "<p>{$this->text}</p>";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Alert/Components/TitleComponent.php | src/Alert/Components/TitleComponent.php | <?php
namespace TCG\Voyager\Alert\Components;
class TitleComponent extends AbstractComponent
{
protected $title;
public function create($title)
{
$this->title = $title;
}
public function render()
{
return "<strong>{$this->title}</strong>";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Alert/Components/ButtonComponent.php | src/Alert/Components/ButtonComponent.php | <?php
namespace TCG\Voyager\Alert\Components;
class ButtonComponent extends AbstractComponent
{
protected $text;
protected $link;
protected $style;
public function create($text, $link = '#', $style = 'default')
{
$this->text = $text;
$this->link = $link;
$this->style = $style;
}
public function render()
{
return "<a href='{$this->link}' class='btn btn-{$this->style}'>{$this->text}</a>";
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Alert/Components/ComponentInterface.php | src/Alert/Components/ComponentInterface.php | <?php
namespace TCG\Voyager\Alert\Components;
interface ComponentInterface
{
public function render();
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Alert/Components/AbstractComponent.php | src/Alert/Components/AbstractComponent.php | <?php
namespace TCG\Voyager\Alert\Components;
use TCG\Voyager\Alert;
abstract class AbstractComponent implements ComponentInterface
{
protected $alert;
public function setAlert(Alert $alert)
{
$this->alert = $alert;
return $this;
}
public function __call($name, $arguments)
{
return call_user_func_array([$this->alert, $name], $arguments);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Page.php | src/Models/Page.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use TCG\Voyager\Traits\Translatable;
class Page extends Model
{
use Translatable;
protected $translatable = ['title', 'slug', 'body'];
/**
* Statuses.
*/
public const STATUS_ACTIVE = 'ACTIVE';
public const STATUS_INACTIVE = 'INACTIVE';
/**
* List of statuses.
*
* @var array
*/
public static $statuses = [self::STATUS_ACTIVE, self::STATUS_INACTIVE];
protected $guarded = [];
public function save(array $options = [])
{
// If no author has been assigned, assign the current user's id as the author of the post
if (!$this->author_id && Auth::user()) {
$this->author_id = Auth::user()->getKey();
}
return parent::save();
}
/**
* Scope a query to only include active pages.
*
* @param $query \Illuminate\Database\Eloquent\Builder
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeActive($query)
{
return $query->where('status', static::STATUS_ACTIVE);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/MenuItem.php | src/Models/MenuItem.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Route;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Traits\Translatable;
class MenuItem extends Model
{
use Translatable;
protected $translatorMethods = [
'link' => 'translatorLink',
];
protected $table = 'menu_items';
protected $guarded = [];
protected $translatable = ['title'];
public static function boot()
{
parent::boot();
static::created(function ($model) {
$model->menu->removeMenuFromCache();
});
static::saved(function ($model) {
$model->menu->removeMenuFromCache();
});
static::deleted(function ($model) {
$model->menu->removeMenuFromCache();
});
}
public function children()
{
return $this->hasMany(Voyager::modelClass('MenuItem'), 'parent_id')
->with('children');
}
public function menu()
{
return $this->belongsTo(Voyager::modelClass('Menu'));
}
public function link($absolute = false)
{
return $this->prepareLink($absolute, $this->route, $this->parameters, $this->url);
}
public function translatorLink($translator, $absolute = false)
{
return $this->prepareLink($absolute, $translator->route, $translator->parameters, $translator->url);
}
protected function prepareLink($absolute, $route, $parameters, $url)
{
if (is_null($parameters)) {
$parameters = [];
}
if (is_string($parameters)) {
$parameters = json_decode($parameters, true);
} elseif (is_array($parameters)) {
$parameters = $parameters;
} elseif (is_object($parameters)) {
$parameters = json_decode(json_encode($parameters), true);
}
if (!is_null($route)) {
if (!Route::has($route)) {
return '#';
}
return route($route, $parameters, $absolute);
}
if ($absolute) {
return url($url);
}
return $url;
}
public function getParametersAttribute()
{
return json_decode($this->attributes['parameters'] ?? '');
}
public function setParametersAttribute($value)
{
if (is_array($value)) {
$value = json_encode($value);
}
$this->attributes['parameters'] = $value;
}
public function setUrlAttribute($value)
{
if (is_null($value)) {
$value = '';
}
$this->attributes['url'] = $value;
}
/**
* Return the Highest Order Menu Item.
*
* @param number $parent (Optional) Parent id. Default null
*
* @return number Order number
*/
public function highestOrderMenuItem($parent = null)
{
$order = 1;
$item = $this->where('parent_id', '=', $parent)
->orderBy('order', 'DESC')
->first();
if (!is_null($item)) {
$order = intval($item->order) + 1;
}
return $order;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Translation.php | src/Models/Translation.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
class Translation extends Model
{
protected $table = 'translations';
protected $fillable = ['table_name', 'column_name', 'foreign_key', 'locale', 'value'];
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/User.php | src/Models/User.php | <?php
namespace TCG\Voyager\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TCG\Voyager\Contracts\User as UserContract;
use TCG\Voyager\Tests\Database\Factories\UserFactory;
use TCG\Voyager\Traits\VoyagerUser;
class User extends Authenticatable implements UserContract
{
use VoyagerUser, HasFactory;
protected $guarded = [];
public $additional_attributes = ['locale'];
public function getAvatarAttribute($value)
{
return $value ?? config('voyager.user.default_avatar', 'users/default.png');
}
public function setCreatedAtAttribute($value)
{
$this->attributes['created_at'] = Carbon::parse($value)->format('Y-m-d H:i:s');
}
public function setSettingsAttribute($value)
{
$this->attributes['settings'] = $value ? $value->toJson() : json_encode([]);
}
public function getSettingsAttribute($value)
{
return collect(json_decode((string)$value));
}
public function setLocaleAttribute($value)
{
$this->settings = $this->settings->merge(['locale' => $value]);
}
public function getLocaleAttribute()
{
return $this->settings->get('locale');
}
protected static function newFactory()
{
return UserFactory::new();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Menu.php | src/Models/Menu.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Events\MenuDisplay;
use TCG\Voyager\Facades\Voyager;
/**
* @todo: Refactor this class by using something like MenuBuilder Helper.
*/
class Menu extends Model
{
protected $table = 'menus';
protected $guarded = [];
public static function boot()
{
parent::boot();
static::saved(function ($model) {
$model->removeMenuFromCache();
});
static::deleted(function ($model) {
$model->removeMenuFromCache();
});
}
public function items()
{
return $this->hasMany(Voyager::modelClass('MenuItem'));
}
public function parent_items()
{
return $this->hasMany(Voyager::modelClass('MenuItem'))
->whereNull('parent_id');
}
/**
* Display menu.
*
* @param string $menuName
* @param string|null $type
* @param array $options
*
* @return string
*/
public static function display($menuName, $type = null, array $options = [])
{
// GET THE MENU - sort collection in blade
$menu = \Cache::remember('voyager_menu_'.$menuName, \Carbon\Carbon::now()->addDays(30), function () use ($menuName) {
return static::where('name', '=', $menuName)
->with(['parent_items.children' => function ($q) {
$q->orderBy('order');
}])
->first();
});
// Check for Menu Existence
if (!isset($menu)) {
return false;
}
event(new MenuDisplay($menu));
// Convert options array into object
$options = (object) $options;
$items = $menu->parent_items->sortBy('order');
if ($menuName == 'admin' && $type == '_json') {
$items = static::processItems($items);
}
if ($type == 'admin') {
$type = 'voyager::menu.'.$type;
} else {
if (is_null($type)) {
$type = 'voyager::menu.default';
} elseif ($type == 'bootstrap' && !view()->exists($type)) {
$type = 'voyager::menu.bootstrap';
}
}
if (!isset($options->locale)) {
$options->locale = app()->getLocale();
}
if ($type === '_json') {
return $items;
}
return new \Illuminate\Support\HtmlString(
\Illuminate\Support\Facades\View::make($type, ['items' => $items, 'options' => $options])->render()
);
}
public function removeMenuFromCache()
{
\Cache::forget('voyager_menu_'.$this->name);
}
protected static function processItems($items)
{
// Eagerload Translations
if (config('voyager.multilingual.enabled')) {
$items->load('translations');
}
$items = $items->transform(function ($item) {
// Translate title
$item->title = $item->getTranslatedAttribute('title');
// Resolve URL/Route
$item->href = $item->link(true);
if ($item->href == url()->current() && $item->href != '') {
// The current URL is exactly the URL of the menu-item
$item->active = true;
} elseif (Str::startsWith(url()->current(), Str::finish($item->href, '/'))) {
// The current URL is "below" the menu-item URL. For example "admin/posts/1/edit" => "admin/posts"
$item->active = true;
}
if (($item->href == url('') || $item->href == route('voyager.dashboard')) && $item->children->count() > 0) {
// Exclude sub-menus
$item->active = false;
} elseif ($item->href == route('voyager.dashboard') && url()->current() != route('voyager.dashboard')) {
// Exclude dashboard
$item->active = false;
}
if ($item->children->count() > 0) {
$item->setRelation('children', static::processItems($item->children));
if (!$item->children->where('active', true)->isEmpty()) {
$item->active = true;
}
}
return $item;
});
// Filter items by permission
$items = $items->filter(function ($item) {
return !$item->children->isEmpty() || Auth::user()->can('browse', $item);
})->filter(function ($item) {
// Filter out empty menu-items
if ($item->url == '' && $item->route == '' && $item->children->count() == 0) {
return false;
}
return true;
});
return $items->values();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Category.php | src/Models/Category.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Traits\Translatable;
class Category extends Model
{
use Translatable;
protected $translatable = ['slug', 'name'];
protected $table = 'categories';
protected $fillable = ['slug', 'name'];
public function posts()
{
return $this->hasMany(Voyager::modelClass('Post'))
->published()
->orderBy('created_at', 'DESC');
}
public function parentId()
{
return $this->belongsTo(self::class);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Role.php | src/Models/Role.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Tests\Database\Factories\RoleFactory;
class Role extends Model
{
use HasFactory;
protected $guarded = [];
public function users()
{
$userModel = Voyager::modelClass('User');
return $this->belongsToMany($userModel, 'user_roles')
->select(app($userModel)->getTable().'.*')
->union($this->hasMany($userModel))->getQuery();
}
public function permissions()
{
return $this->belongsToMany(Voyager::modelClass('Permission'));
}
protected static function newFactory()
{
return RoleFactory::new();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/DataRow.php | src/Models/DataRow.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Traits\Translatable;
class DataRow extends Model
{
use Translatable;
protected $table = 'data_rows';
protected $guarded = [];
public $timestamps = false;
protected $translatable = ['display_name'];
public function rowBefore()
{
$previous = self::where('data_type_id', '=', $this->data_type_id)->where('order', '=', ($this->order - 1))->first();
if (isset($previous->id)) {
return $previous->field;
}
return '__first__';
}
public function relationshipField()
{
return @$this->details->column;
}
/**
* Check if this field is the current filter.
*
* @return bool True if this is the current filter, false otherwise
*/
public function isCurrentSortField($orderBy)
{
return $orderBy == $this->field;
}
/**
* Build the URL to sort data type by this field.
*
* @return string Built URL
*/
public function sortByUrl($orderBy, $sortOrder)
{
$params = [];
$isDesc = $sortOrder != 'asc';
if ($this->isCurrentSortField($orderBy) && $isDesc) {
$params['sort_order'] = 'asc';
} else {
$params['sort_order'] = 'desc';
}
$params['order_by'] = $this->field;
return url()->current().'?'.http_build_query(array_merge(\Request::all(), $params));
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value);
}
public function getDetailsAttribute($value)
{
return json_decode(!empty($value) ? $value : '{}');
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Permission.php | src/Models/Permission.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Facades\Voyager;
class Permission extends Model
{
protected $guarded = [];
public function roles()
{
return $this->belongsToMany(Voyager::modelClass('Role'));
}
public static function generateFor($table_name)
{
self::firstOrCreate(['key' => 'browse_'.$table_name, 'table_name' => $table_name]);
self::firstOrCreate(['key' => 'read_'.$table_name, 'table_name' => $table_name]);
self::firstOrCreate(['key' => 'edit_'.$table_name, 'table_name' => $table_name]);
self::firstOrCreate(['key' => 'add_'.$table_name, 'table_name' => $table_name]);
self::firstOrCreate(['key' => 'delete_'.$table_name, 'table_name' => $table_name]);
}
public static function removeFrom($table_name)
{
self::where(['table_name' => $table_name])->delete();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Setting.php | src/Models/Setting.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Events\SettingUpdated;
class Setting extends Model
{
protected $table = 'settings';
protected $guarded = [];
public $timestamps = false;
protected $dispatchesEvents = [
'updating' => SettingUpdated::class,
];
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/Post.php | src/Models/Post.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Traits\Resizable;
use TCG\Voyager\Traits\Translatable;
class Post extends Model
{
use Translatable;
use Resizable;
protected $translatable = ['title', 'seo_title', 'excerpt', 'body', 'slug', 'meta_description', 'meta_keywords'];
public const PUBLISHED = 'PUBLISHED';
protected $guarded = [];
public function save(array $options = [])
{
// If no author has been assigned, assign the current user's id as the author of the post
if (!$this->author_id && Auth::user()) {
$this->author_id = Auth::user()->getKey();
}
return parent::save();
}
public function authorId()
{
return $this->belongsTo(Voyager::modelClass('User'), 'author_id', 'id');
}
/**
* Scope a query to only published scopes.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopePublished(Builder $query)
{
return $query->where('status', '=', static::PUBLISHED);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function category()
{
return $this->belongsTo(Voyager::modelClass('Category'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Models/DataType.php | src/Models/DataType.php | <?php
namespace TCG\Voyager\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use TCG\Voyager\Database\Schema\SchemaManager;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Traits\Translatable;
class DataType extends Model
{
use Translatable;
protected $translatable = ['display_name_singular', 'display_name_plural'];
protected $table = 'data_types';
protected $fillable = [
'name',
'slug',
'display_name_singular',
'display_name_plural',
'icon',
'model_name',
'policy_name',
'controller',
'description',
'generate_permissions',
'server_side',
'order_column',
'order_display_column',
'order_direction',
'default_search_key',
'scope',
'details',
];
public function rows()
{
return $this->hasMany(Voyager::modelClass('DataRow'))->orderBy('order');
}
public function browseRows()
{
return $this->rows()->where('browse', 1);
}
public function readRows()
{
return $this->rows()->where('read', 1);
}
public function editRows()
{
return $this->rows()->where('edit', 1);
}
public function addRows()
{
return $this->rows()->where('add', 1);
}
public function deleteRows()
{
return $this->rows()->where('delete', 1);
}
public function lastRow()
{
return $this->hasMany(Voyager::modelClass('DataRow'))->orderBy('order', 'DESC')->first();
}
public function setGeneratePermissionsAttribute($value)
{
$this->attributes['generate_permissions'] = $value ? 1 : 0;
}
public function setServerSideAttribute($value)
{
$this->attributes['server_side'] = $value ? 1 : 0;
}
public function updateDataType($requestData, $throw = false)
{
try {
DB::beginTransaction();
// Prepare data
foreach (['generate_permissions', 'server_side'] as $field) {
if (!isset($requestData[$field])) {
$requestData[$field] = 0;
}
}
if ($this->fill($requestData)->save()) {
$fields = $this->fields(
(strlen($this->model_name) != 0)
? DB::getTablePrefix().app($this->model_name)->getTable()
: DB::getTablePrefix().Arr::get($requestData, 'name')
);
$requestData = $this->getRelationships($requestData, $fields);
foreach ($fields as $field) {
$dataRow = $this->rows()->firstOrNew(['field' => $field]);
foreach (['browse', 'read', 'edit', 'add', 'delete'] as $check) {
$dataRow->{$check} = isset($requestData["field_{$check}_{$field}"]);
}
$dataRow->required = !empty($requestData['field_required_'.$field]);
$dataRow->field = $requestData['field_'.$field];
$dataRow->type = $requestData['field_input_type_'.$field];
$dataRow->details = json_decode($requestData['field_details_'.$field]);
$dataRow->display_name = $requestData['field_display_name_'.$field];
$dataRow->order = intval($requestData['field_order_'.$field]);
// Prepare Translations and Transform data
$translations = (is_bread_translatable($dataRow) && !empty($requestData['field_display_name_'.$field.'_i18n']))
? $dataRow->prepareTranslationsFromArray($field, $requestData)
: [];
if (!$dataRow->save()) {
throw new \Exception(__('voyager::database.field_safe_failed', ['field' => $field]));
}
// Save translations if applied
$dataRow->saveTranslations($translations);
}
// Clean data_rows that don't have an associated field
// TODO: need a way to identify deleted and renamed fields.
// maybe warn the user and let him decide to either rename or delete?
$this->rows()->whereNotIn('field', $fields)->delete();
// It seems everything was fine. Let's check if we need to generate permissions
if ($this->generate_permissions) {
Voyager::model('Permission')->generateFor($this->name);
}
DB::commit();
return true;
}
} catch (\Exception $e) {
DB::rollBack();
if ($throw) {
throw $e;
}
}
return false;
}
public function fields($name = null)
{
if (is_null($name)) {
$name = $this->name;
}
$fields = SchemaManager::listTableColumnNames($name);
if ($extraFields = $this->extraFields()) {
foreach ($extraFields as $field) {
$fields[] = $field['Field'];
}
}
return $fields;
}
public function getRelationships($requestData, &$fields)
{
if (isset($requestData['relationships'])) {
$relationships = $requestData['relationships'];
if (count($relationships) > 0) {
foreach ($relationships as $index => $relationship) {
// Push the relationship on the allowed fields
array_push($fields, $relationship);
$relationship_column = $requestData['relationship_column_belongs_to_'.$relationship];
if ($requestData['relationship_type_'.$relationship] == 'hasOne' || $requestData['relationship_type_'.$relationship] == 'hasMany') {
$relationship_column = $requestData['relationship_column_'.$relationship];
}
// Build the relationship details
$relationshipDetails = [
'model' => $requestData['relationship_model_'.$relationship],
'table' => $requestData['relationship_table_'.$relationship],
'type' => $requestData['relationship_type_'.$relationship],
'column' => $relationship_column,
'key' => $requestData['relationship_key_'.$relationship],
'label' => $requestData['relationship_label_'.$relationship],
'pivot_table' => $requestData['relationship_pivot_table_'.$relationship],
'pivot' => ($requestData['relationship_type_'.$relationship] == 'belongsToMany') ? '1' : '0',
'taggable' => $requestData['relationship_taggable_'.$relationship] ?? '0',
];
$details = json_decode($requestData['field_details_'.$relationship], true);
$merge = array_merge($details, $relationshipDetails);
$requestData['field_details_'.$relationship] = json_encode($merge);
}
}
}
return $requestData;
}
public function fieldOptions()
{
// Get ordered BREAD fields
$orderedFields = $this->rows()->pluck('field')->toArray();
$_fieldOptions = SchemaManager::describeTable(
(strlen($this->model_name) != 0)
? app($this->model_name)->getTable()
: $this->name
)->toArray();
$fieldOptions = [];
$f_size = count($orderedFields);
for ($i = 0; $i < $f_size; $i++) {
$fieldOptions[$orderedFields[$i]] = $_fieldOptions[$orderedFields[$i]];
}
$fieldOptions = collect($fieldOptions);
if ($extraFields = $this->extraFields()) {
foreach ($extraFields as $field) {
$fieldOptions[] = (object) $field;
}
}
return $fieldOptions;
}
public function extraFields()
{
if (empty(trim($this->model_name))) {
return [];
}
$model = app($this->model_name);
if (method_exists($model, 'adminFields')) {
return $model->adminFields();
}
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value);
}
public function getDetailsAttribute($value)
{
return json_decode(!empty($value) ? $value : '{}');
}
public function getOrderColumnAttribute()
{
return $this->details->order_column ?? null;
}
public function setOrderColumnAttribute($value)
{
$this->attributes['details'] = collect($this->details)->merge(['order_column' => $value]);
}
public function getOrderDisplayColumnAttribute()
{
return $this->details->order_display_column ?? null;
}
public function setOrderDisplayColumnAttribute($value)
{
$this->attributes['details'] = collect($this->details)->merge(['order_display_column' => $value]);
}
public function getDefaultSearchKeyAttribute()
{
return $this->details->default_search_key ?? null;
}
public function setDefaultSearchKeyAttribute($value)
{
$this->attributes['details'] = collect($this->details)->merge(['default_search_key' => $value]);
}
public function getOrderDirectionAttribute()
{
return $this->details->order_direction ?? 'desc';
}
public function setOrderDirectionAttribute($value)
{
$this->attributes['details'] = collect($this->details)->merge(['order_direction' => $value]);
}
public function getScopeAttribute()
{
return $this->details->scope ?? null;
}
public function setScopeAttribute($value)
{
$this->attributes['details'] = collect($this->details)->merge(['scope' => $value]);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Commands/ControllersCommand.php | src/Commands/ControllersCommand.php | <?php
namespace TCG\Voyager\Commands;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputOption;
class ControllersCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'voyager:controllers';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Publish all the controllers from Voyager.';
/**
* The Filesystem instance.
*
* @var Filesystem
*/
protected $filesystem;
/**
* Filename of stub-file.
*
* @var string
*/
protected $stub = 'controller.stub';
/**
* Create a new command instance.
*
* @param Filesystem $filesystem
*/
public function __construct(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
parent::__construct();
}
public function fire()
{
return $this->handle();
}
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$stub = $this->getStub();
$files = $this->filesystem->files(base_path('vendor/tcg/voyager/src/Http/Controllers'));
$namespace = config('voyager.controllers.namespace', 'TCG\\Voyager\\Http\\Controllers');
$appNamespace = app()->getNamespace();
if (!Str::startsWith($namespace, $appNamespace)) {
return $this->error('The controllers namespace must start with your application namespace: '.$appNamespace);
}
$location = str_replace('\\', DIRECTORY_SEPARATOR, substr($namespace, strlen($appNamespace)));
if (!$this->filesystem->isDirectory(app_path($location))) {
$this->filesystem->makeDirectory(app_path($location));
}
foreach ($files as $file) {
$parts = explode(DIRECTORY_SEPARATOR, $file);
$filename = end($parts);
if ($filename == 'Controller.php') {
continue;
}
$path = app_path($location.DIRECTORY_SEPARATOR.$filename);
if (!$this->filesystem->exists($path) or $this->option('force')) {
$class = substr($filename, 0, strpos($filename, '.'));
$content = $this->generateContent($stub, $class);
$this->filesystem->put($path, $content);
}
}
$this->info('Published Voyager controllers!');
}
/**
* Get stub content.
*
* @return string
*/
public function getStub()
{
return $this->filesystem->get(base_path('/vendor/tcg/voyager/stubs/'.$this->stub));
}
/**
* Generate real content from stub.
*
* @param $stub
* @param $class
*
* @return mixed
*/
protected function generateContent($stub, $class)
{
$namespace = config('voyager.controllers.namespace', 'TCG\\Voyager\\Http\\Controllers');
$content = str_replace(
'DummyNamespace',
$namespace,
$stub
);
$content = str_replace(
'FullBaseDummyClass',
'TCG\\Voyager\\Http\\Controllers\\'.$class,
$content
);
$content = str_replace(
'BaseDummyClass',
'Base'.$class,
$content
);
$content = str_replace(
'DummyClass',
$class,
$content
);
return $content;
}
/**
* Get command options.
*
* @return array
*/
protected function getOptions()
{
return [
['force', 'f', InputOption::VALUE_NONE, 'Overwrite existing controller files'],
];
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Commands/InstallCommand.php | src/Commands/InstallCommand.php | <?php
namespace TCG\Voyager\Commands;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Composer;
use Symfony\Component\Console\Input\InputOption;
use TCG\Voyager\Providers\VoyagerDummyServiceProvider;
use TCG\Voyager\VoyagerServiceProvider;
class InstallCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'voyager:install';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install the Voyager Admin package';
/**
* The Composer instance.
*
* @var \Illuminate\Foundation\Composer
*/
protected $composer;
/**
* Seed Folder name.
*
* @var string
*/
protected $seedFolder;
public function __construct(Composer $composer)
{
parent::__construct();
$this->composer = $composer;
$this->composer->setWorkingPath(base_path());
}
protected function getOptions()
{
return [
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production', null],
['with-dummy', null, InputOption::VALUE_NONE, 'Install with dummy data', null],
];
}
/**
* Get the composer command for the environment.
*
* @return string
*/
protected function findComposer()
{
if (file_exists(getcwd().'/composer.phar')) {
return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar';
}
return 'composer';
}
public function fire(Filesystem $filesystem)
{
return $this->handle($filesystem);
}
/**
* Execute the console command.
*
* @param \Illuminate\Filesystem\Filesystem $filesystem
*
* @return void
*/
public function handle(Filesystem $filesystem)
{
$this->info('Publishing the Voyager assets, database, and config files');
// Publish only relevant resources on install
$tags = ['seeders'];
$this->call('vendor:publish', ['--provider' => VoyagerServiceProvider::class, '--tag' => $tags]);
$this->info('Migrating the database tables into your application');
$this->call('migrate', ['--force' => $this->option('force')]);
$this->info('Attempting to set Voyager User model as parent to App\User');
if (file_exists(app_path('User.php')) || file_exists(app_path('Models/User.php'))) {
$userPath = file_exists(app_path('User.php')) ? app_path('User.php') : app_path('Models/User.php');
$str = file_get_contents($userPath);
if ($str !== false) {
$str = str_replace('extends Authenticatable', "extends \TCG\Voyager\Models\User", $str);
file_put_contents($userPath, $str);
}
} else {
$this->warn('Unable to locate "User.php" in app or app/Models. Did you move this file?');
$this->warn('You will need to update this manually. Change "extends Authenticatable" to "extends \TCG\Voyager\Models\User" in your User model');
}
$this->info('Adding Voyager routes to routes/web.php');
$routes_contents = $filesystem->get(base_path('routes/web.php'));
if (false === strpos($routes_contents, 'Voyager::routes()')) {
$filesystem->append(
base_path('routes/web.php'),
PHP_EOL.PHP_EOL."Route::group(['prefix' => 'admin'], function () {".PHP_EOL." Voyager::routes();".PHP_EOL."});".PHP_EOL
);
}
$publishablePath = dirname(__DIR__).'/../publishable';
if ($this->option('with-dummy')) {
$this->info('Publishing dummy content');
$tags = ['dummy_seeders', 'dummy_content', 'dummy_config', 'dummy_migrations'];
$this->call('vendor:publish', ['--provider' => VoyagerDummyServiceProvider::class, '--tag' => $tags]);
} else {
$this->call('vendor:publish', ['--provider' => VoyagerServiceProvider::class, '--tag' => ['config', 'voyager_avatar']]);
}
$this->info('Dumping the autoloaded files and reloading all new files');
$this->composer->dumpAutoloads();
$this->info('Seeding data into the database');
$this->call('db:seed', ['--class' => 'VoyagerDatabaseSeeder', '--force' => $this->option('force')]);
if ($this->option('with-dummy')) {
$this->info('Migrating dummy tables');
$this->call('migrate');
$this->info('Seeding dummy data');
$this->call('db:seed', ['--class' => 'VoyagerDummyDatabaseSeeder', '--force' => $this->option('force')]);
}
$this->info('Adding the storage symlink to your public folder');
$this->call('storage:link');
$this->info('Successfully installed Voyager! Enjoy');
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Commands/AdminCommand.php | src/Commands/AdminCommand.php | <?php
namespace TCG\Voyager\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputOption;
use TCG\Voyager\Facades\Voyager;
class AdminCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'voyager:admin';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make sure there is a user with the admin role that has all of the necessary permissions.';
/**
* Get user options.
*/
protected function getOptions()
{
return [
['create', null, InputOption::VALUE_NONE, 'Create an admin user', null],
];
}
public function fire()
{
return $this->handle();
}
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
// Get or create user
$user = $this->getUser(
$this->option('create')
);
// the user not returned
if (!$user) {
exit;
}
// Get or create role
$role = $this->getAdministratorRole();
// Get all permissions
$permissions = Voyager::model('Permission')->all();
// Assign all permissions to the admin role
$role->permissions()->sync(
$permissions->pluck('id')->all()
);
// Ensure that the user is admin
$user->role_id = $role->id;
$user->save();
$this->info('The user now has full access to your site.');
}
/**
* Get command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['email', InputOption::VALUE_REQUIRED, 'The email of the user.', null],
];
}
/**
* Get the administrator role, create it if it does not exists.
*
* @return mixed
*/
protected function getAdministratorRole()
{
$role = Voyager::model('Role')->firstOrNew([
'name' => 'admin',
]);
if (!$role->exists) {
$role->fill([
'display_name' => 'Administrator',
])->save();
}
return $role;
}
/**
* Get or create user.
*
* @param bool $create
*
* @return \App\User
*/
protected function getUser($create = false)
{
$email = $this->argument('email');
$model = Auth::guard(app('VoyagerGuard'))->getProvider()->getModel();
$model = Str::start($model, '\\');
// If we need to create a new user go ahead and create it
if ($create) {
$name = $this->ask('Enter the admin name');
$password = $this->secret('Enter admin password');
$confirmPassword = $this->secret('Confirm Password');
// Ask for email if there wasnt set one
if (!$email) {
$email = $this->ask('Enter the admin email');
}
// check if user with given email exists
if ($model::where('email', $email)->exists()) {
$this->info("Can't create user. User with the email ".$email.' exists already.');
return;
}
// Passwords don't match
if ($password != $confirmPassword) {
$this->info("Passwords don't match");
return;
}
$this->info('Creating admin account');
return call_user_func($model.'::forceCreate', [
'name' => $name,
'email' => $email,
'password' => Hash::make($password),
]);
}
return call_user_func($model.'::where', 'email', $email)->firstOrFail();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Commands/MakeModelCommand.php | src/Commands/MakeModelCommand.php | <?php
namespace TCG\Voyager\Commands;
use Illuminate\Foundation\Console\ModelMakeCommand;
use Symfony\Component\Console\Input\InputOption;
class MakeModelCommand extends ModelMakeCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'voyager:make:model';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new Voyager model class';
/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/../../stubs/model.stub';
}
/**
* Build the class with the given name.
*
* @param string $name
*
* @return string
*/
protected function buildClass($name)
{
$stub = $this->files->get($this->getStub());
return $this->addSoftDelete($stub)->replaceNamespace($stub, $name)->replaceClass($stub, $name);
}
/**
* Add SoftDelete to the given stub.
*
* @param string $stub
*
* @return $this
*/
protected function addSoftDelete(&$stub)
{
$traitIncl = $trait = '';
if ($this->option('softdelete')) {
$traitIncl = 'use Illuminate\Database\Eloquent\SoftDeletes;';
$trait = 'use SoftDeletes;';
}
$stub = str_replace('//DummySDTraitInclude', $traitIncl, $stub);
$stub = str_replace('//DummySDTrait', $trait, $stub);
return $this;
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
$options = [
['softdelete', 'd', InputOption::VALUE_NONE, 'Add soft-delete field to Model'],
];
return array_merge($options, parent::getOptions());
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Widgets/PageDimmer.php | src/Widgets/PageDimmer.php | <?php
namespace TCG\Voyager\Widgets;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
class PageDimmer extends BaseDimmer
{
/**
* The configuration array.
*
* @var array
*/
protected $config = [];
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
$count = Voyager::model('Page')->count();
$string = trans_choice('voyager::dimmer.page', $count);
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-file-text',
'title' => "{$count} {$string}",
'text' => __('voyager::dimmer.page_text', ['count' => $count, 'string' => Str::lower($string)]),
'button' => [
'text' => __('voyager::dimmer.page_link_text'),
'link' => route('voyager.pages.index'),
],
'image' => voyager_asset('images/widget-backgrounds/03.jpg'),
]));
}
/**
* Determine if the widget should be displayed.
*
* @return bool
*/
public function shouldBeDisplayed()
{
return Auth::user()->can('browse', Voyager::model('Page'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Widgets/BaseDimmer.php | src/Widgets/BaseDimmer.php | <?php
namespace TCG\Voyager\Widgets;
use Arrilot\Widgets\AbstractWidget;
abstract class BaseDimmer extends AbstractWidget
{
/**
* Determine if the widget should be displayed.
*
* @return bool
*/
public function shouldBeDisplayed()
{
return true;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Widgets/UserDimmer.php | src/Widgets/UserDimmer.php | <?php
namespace TCG\Voyager\Widgets;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
class UserDimmer extends BaseDimmer
{
/**
* The configuration array.
*
* @var array
*/
protected $config = [];
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
$count = Voyager::model('User')->count();
$string = trans_choice('voyager::dimmer.user', $count);
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-group',
'title' => "{$count} {$string}",
'text' => __('voyager::dimmer.user_text', ['count' => $count, 'string' => Str::lower($string)]),
'button' => [
'text' => __('voyager::dimmer.user_link_text'),
'link' => route('voyager.users.index'),
],
'image' => voyager_asset('images/widget-backgrounds/01.jpg'),
]));
}
/**
* Determine if the widget should be displayed.
*
* @return bool
*/
public function shouldBeDisplayed()
{
return Auth::user()->can('browse', Voyager::model('User'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Widgets/PostDimmer.php | src/Widgets/PostDimmer.php | <?php
namespace TCG\Voyager\Widgets;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
class PostDimmer extends BaseDimmer
{
/**
* The configuration array.
*
* @var array
*/
protected $config = [];
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
$count = Voyager::model('Post')->count();
$string = trans_choice('voyager::dimmer.post', $count);
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-news',
'title' => "{$count} {$string}",
'text' => __('voyager::dimmer.post_text', ['count' => $count, 'string' => Str::lower($string)]),
'button' => [
'text' => __('voyager::dimmer.post_link_text'),
'link' => route('voyager.posts.index'),
],
'image' => voyager_asset('images/widget-backgrounds/02.jpg'),
]));
}
/**
* Determine if the widget should be displayed.
*
* @return bool
*/
public function shouldBeDisplayed()
{
return Auth::user()->can('browse', Voyager::model('Post'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Providers/VoyagerDummyServiceProvider.php | src/Providers/VoyagerDummyServiceProvider.php | <?php
namespace TCG\Voyager\Providers;
use Arrilot\Widgets\ServiceProvider as WidgetServiceProvider;
use Illuminate\Support\ServiceProvider;
use TCG\Voyager\Seed;
class VoyagerDummyServiceProvider extends ServiceProvider
{
/**
* Register the application services.
*/
public function register()
{
$this->app->register(WidgetServiceProvider::class);
$this->registerConfigs();
if ($this->app->runningInConsole()) {
$this->registerPublishableResources();
}
}
/**
* Register the publishable files.
*/
private function registerPublishableResources()
{
$publishablePath = dirname(__DIR__).'/../publishable';
$publishable = [
'dummy_seeders' => [
"{$publishablePath}/database/dummy_seeders/" => database_path('seeders'),
],
'dummy_content' => [
"{$publishablePath}/dummy_content/" => storage_path('app/public'),
],
'dummy_config' => [
"{$publishablePath}/config/voyager_dummy.php" => config_path('voyager.php'),
],
'dummy_migrations' => [
"{$publishablePath}/database/migrations/" => database_path('migrations'),
],
];
foreach ($publishable as $group => $paths) {
$this->publishes($paths, $group);
}
}
public function registerConfigs()
{
$this->mergeConfigFrom(
dirname(__DIR__).'/../publishable/config/voyager_dummy.php',
'voyager'
);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Providers/VoyagerEventServiceProvider.php | src/Providers/VoyagerEventServiceProvider.php | <?php
namespace TCG\Voyager\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use TCG\Voyager\Events;
use TCG\Voyager\Listeners;
class VoyagerEventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Events\BreadAdded::class => [
Listeners\AddBreadMenuItem::class,
Listeners\AddBreadPermission::class,
],
Events\BreadDeleted::class => [
Listeners\DeleteBreadMenuItem::class,
],
Events\SettingUpdated::class => [
Listeners\ClearCachedSettingValue::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/Routing.php | src/Events/Routing.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class Routing
{
use SerializesModels;
public $router;
public function __construct()
{
$this->router = app('router');
// @deprecate
//
event('voyager.routing', $this->router);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/RoutingAdminAfter.php | src/Events/RoutingAdminAfter.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class RoutingAdminAfter
{
use SerializesModels;
public $router;
public function __construct()
{
$this->router = app('router');
// @deprecate
//
event('voyager.admin.routing.after', $this->router);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadDataAdded.php | src/Events/BreadDataAdded.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadDataAdded
{
use SerializesModels;
public $dataType;
public $data;
public function __construct(DataType $dataType, $data)
{
$this->dataType = $dataType;
$this->data = $data;
event(new BreadDataChanged($dataType, $data, 'Added'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/TableChanged.php | src/Events/TableChanged.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class TableChanged
{
use SerializesModels;
public $name;
public function __construct($name)
{
$this->name = $name;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadImagesDeleted.php | src/Events/BreadImagesDeleted.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class BreadImagesDeleted
{
use SerializesModels;
public $data;
public $images;
public function __construct($data, $images)
{
$this->data = $data;
$this->images = $images;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/RoutingAfter.php | src/Events/RoutingAfter.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class RoutingAfter
{
use SerializesModels;
public $router;
public function __construct()
{
$this->router = app('router');
// @deprecate
//
event('voyager.routing.after', $this->router);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadDataDeleted.php | src/Events/BreadDataDeleted.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadDataDeleted
{
use SerializesModels;
public $dataType;
public $data;
public function __construct(DataType $dataType, $data)
{
$this->dataType = $dataType;
$this->data = $data;
event(new BreadDataChanged($dataType, $data, 'Deleted'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadDataRestored.php | src/Events/BreadDataRestored.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadDataRestored
{
use SerializesModels;
public $dataType;
public $data;
public function __construct(DataType $dataType, $data)
{
$this->dataType = $dataType;
$this->data = $data;
event(new BreadDataChanged($dataType, $data, 'Restored'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/MenuDisplay.php | src/Events/MenuDisplay.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\Menu;
class MenuDisplay
{
use SerializesModels;
public $menu;
public function __construct(Menu $menu)
{
$this->menu = $menu;
// @deprecate
//
event('voyager.menu.display', $menu);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadChanged.php | src/Events/BreadChanged.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadChanged
{
use SerializesModels;
public $dataType;
public $data;
public $changeType;
public function __construct(DataType $dataType, $data, $changeType)
{
$this->dataType = $dataType;
$this->data = $data;
$this->changeType = $changeType;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/TableDeleted.php | src/Events/TableDeleted.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class TableDeleted
{
use SerializesModels;
public $name;
public function __construct($name)
{
$this->name = $name;
event(new TableChanged($name, 'Deleted'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadUpdated.php | src/Events/BreadUpdated.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadUpdated
{
use SerializesModels;
public $dataType;
public $data;
public function __construct(DataType $dataType, $data)
{
$this->dataType = $dataType;
$this->data = $data;
event(new BreadChanged($dataType, $data, 'Updated'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/SettingUpdated.php | src/Events/SettingUpdated.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\Setting;
class SettingUpdated
{
use SerializesModels;
public $setting;
public function __construct(Setting $setting)
{
$this->setting = $setting;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadDataUpdated.php | src/Events/BreadDataUpdated.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadDataUpdated
{
use SerializesModels;
public $dataType;
public $data;
public function __construct(DataType $dataType, $data)
{
$this->dataType = $dataType;
$this->data = $data;
event(new BreadDataChanged($dataType, $data, 'Updated'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/TableAdded.php | src/Events/TableAdded.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Database\Schema\Table;
class TableAdded
{
use SerializesModels;
public $table;
public function __construct(Table $table)
{
$this->table = $table;
event(new TableChanged($table->name, 'Added'));
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/FormFieldsRegistered.php | src/Events/FormFieldsRegistered.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
class FormFieldsRegistered
{
use SerializesModels;
public $fields;
public function __construct(array $fields)
{
$this->fields = $fields;
// @deprecate
//
event('voyager.form-fields.registered', $fields);
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/FileDeleted.php | src/Events/FileDeleted.php | <?php
namespace TCG\Voyager\Events;
class FileDeleted
{
public $path;
public function __construct($path)
{
$this->path = $path;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
thedevdojo/voyager | https://github.com/thedevdojo/voyager/blob/7e7e0f4f0e115d2d9e0481a86153a1ceff194c00/src/Events/BreadDataChanged.php | src/Events/BreadDataChanged.php | <?php
namespace TCG\Voyager\Events;
use Illuminate\Queue\SerializesModels;
use TCG\Voyager\Models\DataType;
class BreadDataChanged
{
use SerializesModels;
public $dataType;
public $data;
public $changeType;
public function __construct(DataType $dataType, $data, $changeType)
{
$this->dataType = $dataType;
$this->data = $data;
$this->changeType = $changeType;
}
}
| php | MIT | 7e7e0f4f0e115d2d9e0481a86153a1ceff194c00 | 2026-01-04T15:03:42.463743Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.