1 | <?php |
||
2 | |||
3 | namespace Staudenmeir\LaravelMigrationViews\Schema\Builders; |
||
4 | |||
5 | use Illuminate\Database\Schema\SqlServerBuilder as Base; |
||
6 | |||
7 | class SqlServerBuilder extends Base |
||
8 | { |
||
9 | use ManagesViews { |
||
10 | createView as createViewParent; |
||
11 | } |
||
12 | |||
13 | /** |
||
14 | * Create a new view on the schema. |
||
15 | * |
||
16 | * @param string $name |
||
17 | * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|string $query |
||
18 | * @param array|null $columns |
||
19 | * @param bool $orReplace |
||
20 | * @param bool $materialized |
||
21 | * @return void |
||
22 | */ |
||
23 | public function createView($name, $query, ?array $columns = null, $orReplace = false, bool $materialized = false) |
||
0 ignored issues
–
show
|
|||
24 | { |
||
25 | if ($orReplace) { |
||
26 | $this->dropViewIfExists($name); |
||
27 | } |
||
28 | |||
29 | $this->createViewParent($name, $query, $columns); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Drop a view from the schema. |
||
34 | * |
||
35 | * @param string $name |
||
36 | * @param bool $ifExists |
||
37 | * @return void |
||
38 | */ |
||
39 | public function dropView($name, $ifExists = false) |
||
40 | { |
||
41 | $this->connection->statement( |
||
42 | $this->grammar->compileDropView($name, $ifExists), |
||
43 | $ifExists ? [$this->connection->getTablePrefix().$name] : [] |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get the column listing for a given view. |
||
49 | * |
||
50 | * @param string $name |
||
51 | * @return array |
||
52 | */ |
||
53 | public function getViewColumnListing($name) |
||
54 | { |
||
55 | $results = $this->connection->selectFromWriteConnection( |
||
56 | $this->grammar->compileViewColumnListing(), |
||
57 | [$this->connection->getTablePrefix().$name] |
||
58 | ); |
||
59 | |||
60 | return array_map(fn ($result) => ((object) $result)->name, $results); |
||
61 | } |
||
62 | } |
||
63 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.