Completed
Push — master ( e7b533...82e63d )
by Arjay
01:59
created

OracleBlueprint::nvarchar2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Yajra\Oci8\Schema;
4
5
use Illuminate\Database\Schema\Blueprint;
6
7
class OracleBlueprint extends Blueprint
8
{
9
    /**
10
     * Table comment.
11
     *
12
     * @var string
13
     */
14
    public $comment = null;
15
16
    /**
17
     * Column comments
18
     *
19
     * @var array
20
     */
21
    public $commentColumns = [];
22
23
    /**
24
     * Database prefix variable.
25
     *
26
     * @var string
27
     */
28
    protected $prefix;
29
30
    /**
31
     * Set table prefix settings.
32
     *
33
     * @param string $prefix
34
     */
35
    public function setTablePrefix($prefix = '')
36
    {
37
        $this->prefix = $prefix;
38
    }
39
40
    /**
41
     * Create a default index name for the table.
42
     *
43
     * @param  string $type
44
     * @param  array $columns
45
     * @return string
46
     */
47
    protected function createIndexName($type, array $columns)
48
    {
49
        $short_type = [
50
            'primary' => 'pk',
51
            'foreign' => 'fk',
52
            'unique'  => 'uk',
53
        ];
54
55
        $type = isset($short_type[$type]) ? $short_type[$type] : $type;
56
57
        $index = strtolower($this->prefix . $this->table . '_' . implode('_', $columns) . '_' . $type);
58
59
        // max index name length is 30 chars
60
        return substr(str_replace(['-', '.'], '_', $index), 0, 30);
61
    }
62
63
    /**
64
     * Create a new nvarchar2 column on the table.
65
     *
66
     * @param string $column
67
     * @param int $length
68
     * @return \Illuminate\Support\Fluent
69
     */
70
    public function nvarchar2($column, $length = 255)
71
    {
72
        return $this->addColumn('nvarchar2', $column, compact('length'));
73
    }
74
}
75