1 | <?php |
||||
2 | |||||
3 | namespace Staudenmeir\LaravelMigrationViews\Schema\Grammars; |
||||
4 | |||||
5 | trait CompilesViews |
||||
6 | { |
||||
7 | /** |
||||
8 | * Compile the query to create a view. |
||||
9 | * |
||||
10 | * @param string $name |
||||
11 | * @param string $query |
||||
12 | * @param array|null $columns |
||||
13 | * @param bool $orReplace |
||||
14 | * @param bool $materialized |
||||
15 | * @return string |
||||
16 | */ |
||||
17 | public function compileCreateView($name, $query, $columns, $orReplace, bool $materialized = false) |
||||
18 | { |
||||
19 | $orReplaceSql = $orReplace ? 'or replace ' : ''; |
||||
20 | |||||
21 | $materializedSql = $materialized ? 'materialized ' : ''; |
||||
22 | |||||
23 | $columns = $columns ? '('.$this->columnize($columns).') ' : ''; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
24 | |||||
25 | return 'create '.$orReplaceSql.$materializedSql.'view '.$this->wrapTable($name).' '.$columns.'as '.$query; |
||||
0 ignored issues
–
show
It seems like
wrapTable() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
26 | } |
||||
27 | |||||
28 | /** |
||||
29 | * Compile the query to drop a view. |
||||
30 | * |
||||
31 | * @param string $name |
||||
32 | * @param bool $ifExists |
||||
33 | * @return string |
||||
34 | */ |
||||
35 | public function compileDropView($name, $ifExists) |
||||
36 | { |
||||
37 | $ifExists = $ifExists ? 'if exists ' : ''; |
||||
38 | |||||
39 | return 'drop view '.$ifExists.$this->wrapTable($name); |
||||
40 | } |
||||
41 | |||||
42 | /** |
||||
43 | * Compile the query to refresh a materialized view. |
||||
44 | * |
||||
45 | * @param string $name |
||||
46 | * @return string |
||||
47 | */ |
||||
48 | public function compileRefreshMaterializedView(string $name): string |
||||
49 | { |
||||
50 | return 'refresh materialized view ' . $this->wrapTable($name); |
||||
51 | } |
||||
52 | } |
||||
53 |