PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.3
Independent Analytics – WordPress Analytics Plugin v2.15.3
2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / illuminate / database / Migrations / DatabaseMigrationRepository.php
independent-analytics / vendor / illuminate / database / Migrations Last commit date
stubs 3 weeks ago DatabaseMigrationRepository.php 3 weeks ago Migration.php 2 years ago MigrationCreator.php 3 weeks ago MigrationRepositoryInterface.php 2 years ago Migrator.php 3 weeks ago
DatabaseMigrationRepository.php
193 lines
1 <?php
2
3 namespace IAWPSCOPED\Illuminate\Database\Migrations;
4
5 use IAWPSCOPED\Illuminate\Database\ConnectionResolverInterface as Resolver;
6 /** @internal */
7 class DatabaseMigrationRepository implements MigrationRepositoryInterface
8 {
9 /**
10 * The database connection resolver instance.
11 *
12 * @var \Illuminate\Database\ConnectionResolverInterface
13 */
14 protected $resolver;
15 /**
16 * The name of the migration table.
17 *
18 * @var string
19 */
20 protected $table;
21 /**
22 * The name of the database connection to use.
23 *
24 * @var string
25 */
26 protected $connection;
27 /**
28 * Create a new database migration repository instance.
29 *
30 * @param \Illuminate\Database\ConnectionResolverInterface $resolver
31 * @param string $table
32 * @return void
33 */
34 public function __construct(Resolver $resolver, $table)
35 {
36 $this->table = $table;
37 $this->resolver = $resolver;
38 }
39 /**
40 * Get the completed migrations.
41 *
42 * @return array
43 */
44 public function getRan()
45 {
46 return $this->table()->orderBy('batch', 'asc')->orderBy('migration', 'asc')->pluck('migration')->all();
47 }
48 /**
49 * Get the list of migrations.
50 *
51 * @param int $steps
52 * @return array
53 */
54 public function getMigrations($steps)
55 {
56 $query = $this->table()->where('batch', '>=', '1');
57 return $query->orderBy('batch', 'desc')->orderBy('migration', 'desc')->take($steps)->get()->all();
58 }
59 /**
60 * Get the last migration batch.
61 *
62 * @return array
63 */
64 public function getLast()
65 {
66 $query = $this->table()->where('batch', $this->getLastBatchNumber());
67 return $query->orderBy('migration', 'desc')->get()->all();
68 }
69 /**
70 * Get the completed migrations with their batch numbers.
71 *
72 * @return array
73 */
74 public function getMigrationBatches()
75 {
76 return $this->table()->orderBy('batch', 'asc')->orderBy('migration', 'asc')->pluck('batch', 'migration')->all();
77 }
78 /**
79 * Log that a migration was run.
80 *
81 * @param string $file
82 * @param int $batch
83 * @return void
84 */
85 public function log($file, $batch)
86 {
87 $record = ['migration' => $file, 'batch' => $batch];
88 $this->table()->insert($record);
89 }
90 /**
91 * Remove a migration from the log.
92 *
93 * @param object $migration
94 * @return void
95 */
96 public function delete($migration)
97 {
98 $this->table()->where('migration', $migration->migration)->delete();
99 }
100 /**
101 * Get the next migration batch number.
102 *
103 * @return int
104 */
105 public function getNextBatchNumber()
106 {
107 return $this->getLastBatchNumber() + 1;
108 }
109 /**
110 * Get the last migration batch number.
111 *
112 * @return int
113 */
114 public function getLastBatchNumber()
115 {
116 return $this->table()->max('batch');
117 }
118 /**
119 * Create the migration repository data store.
120 *
121 * @return void
122 */
123 public function createRepository()
124 {
125 $schema = $this->getConnection()->getSchemaBuilder();
126 $schema->create($this->table, function ($table) {
127 // The migrations table is responsible for keeping track of which of the
128 // migrations have actually run for the application. We'll create the
129 // table to hold the migration file's path as well as the batch ID.
130 $table->increments('id');
131 $table->string('migration');
132 $table->integer('batch');
133 });
134 }
135 /**
136 * Determine if the migration repository exists.
137 *
138 * @return bool
139 */
140 public function repositoryExists()
141 {
142 $schema = $this->getConnection()->getSchemaBuilder();
143 return $schema->hasTable($this->table);
144 }
145 /**
146 * Delete the migration repository data store.
147 *
148 * @return void
149 */
150 public function deleteRepository()
151 {
152 $schema = $this->getConnection()->getSchemaBuilder();
153 $schema->drop($this->table);
154 }
155 /**
156 * Get a query builder for the migration table.
157 *
158 * @return \Illuminate\Database\Query\Builder
159 */
160 protected function table()
161 {
162 return $this->getConnection()->table($this->table)->useWritePdo();
163 }
164 /**
165 * Get the connection resolver instance.
166 *
167 * @return \Illuminate\Database\ConnectionResolverInterface
168 */
169 public function getConnectionResolver()
170 {
171 return $this->resolver;
172 }
173 /**
174 * Resolve the database connection instance.
175 *
176 * @return \Illuminate\Database\Connection
177 */
178 public function getConnection()
179 {
180 return $this->resolver->connection($this->connection);
181 }
182 /**
183 * Set the information source to gather data.
184 *
185 * @param string $name
186 * @return void
187 */
188 public function setSource($name)
189 {
190 $this->connection = $name;
191 }
192 }
193