HasMigrations::migrate()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 4
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Epesi\Core\System\Modules\Concerns;
4
5
trait HasMigrations
6
{
7
	use HasModule;
8
	
9
	/**
10
	 * Directory where module migrations are located
11
	 *
12
	 * @return string
13
	 */
14
	public static function migrations()
15
	{
16
		return implode(DIRECTORY_SEPARATOR, [static::relativePath(), 'Database', 'Migrations']);
17
	}
18
	
19
	public function migrate()
20
	{
21
		$paths = $this->migrations();
22
		
23
		foreach (is_array($paths)? $paths: [$paths] as $path) {
24
			\Illuminate\Support\Facades\Artisan::call('migrate', ['--path' => $path, '--force' => true]);
25
		}
26
		
27
		return $this;
28
	}
29
	
30
	public function rollback()
31
	{
32
		$paths = $this->migrations();
33
		
34
		foreach (is_array($paths)? $paths: [$paths] as $path) {
35
			\Illuminate\Support\Facades\Artisan::call('migrate:rollback', ['--path' => $path]);
36
		}
37
		
38
		return $this;
39
	}
40
}
41