1 | <?php |
||
5 | class Blueprint |
||
6 | { |
||
7 | /** |
||
8 | * Default primary key for all blueprints. |
||
9 | * |
||
10 | * @var array |
||
11 | */ |
||
12 | protected static $defaultPrimary = ['id']; |
||
13 | |||
14 | /** |
||
15 | * Table to blueprint. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public $table; |
||
20 | |||
21 | /** |
||
22 | * Array of columns. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | public $columns = []; |
||
27 | |||
28 | /** |
||
29 | * Table primary key. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | public $primary; |
||
34 | |||
35 | /** |
||
36 | * Current column. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $currentColumn = []; |
||
41 | |||
42 | /** |
||
43 | * Callback that builds blueprint. |
||
44 | * |
||
45 | * @var callable |
||
46 | */ |
||
47 | protected $callback; |
||
48 | |||
49 | /** |
||
50 | * Blueprint constructor. |
||
51 | * |
||
52 | * @param string $table |
||
53 | * @param callable|null $callback |
||
54 | */ |
||
55 | public function __construct($table, callable $callback) |
||
60 | |||
61 | /** |
||
62 | * Setter for default primary key. |
||
63 | * |
||
64 | * @param string|array $key |
||
65 | */ |
||
66 | public static function setDefaultPrimary($key) |
||
70 | |||
71 | /** |
||
72 | * Add a column to blueprint. |
||
73 | * |
||
74 | * @param string $name |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function column($name) |
||
88 | |||
89 | /** |
||
90 | * Add where to the current column. |
||
91 | * |
||
92 | * @param string $rawSql |
||
93 | * |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function where($rawSql) |
||
102 | |||
103 | /** |
||
104 | * Set how data should be replaced. |
||
105 | * |
||
106 | * @param callable|string $callback |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | public function replaceWith($callback) |
||
116 | |||
117 | /** |
||
118 | * Build the current blueprint. |
||
119 | * |
||
120 | * @return $this |
||
121 | */ |
||
122 | public function build() |
||
134 | |||
135 | /** |
||
136 | * Setter for a primary key. |
||
137 | * |
||
138 | * @param string|array $key |
||
139 | * |
||
140 | * @return $this |
||
141 | */ |
||
142 | public function primary($key) |
||
148 | } |
||
149 |