MigrationsHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMigrations() 0 5 1
A getExecutedMigrations() 0 4 1
1
<?php
2
3
namespace Turahe\LaravelInstaller\Helpers;
4
5
use Illuminate\Support\Facades\DB;
6
7
/**
8
 * Trait MigrationsHelper.
9
 */
10
trait MigrationsHelper
11
{
12
    /**
13
     * Get the migrations in /database/migrations.
14
     *
15
     * @return array Array of migrations name, empty if no migrations are existing
16
     */
17
    public function getMigrations()
18
    {
19
        $migrations = glob(database_path().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR.'*.php');
20
21
        return str_replace('.php', '', $migrations);
22
    }
23
24
    /**
25
     * Get the migrations that have already been ran.
26
     *
27
     * @return \Illuminate\Support\Collection List of migrations
28
     */
29
    public function getExecutedMigrations()
30
    {
31
        // migrations table should exist, if not, user will receive an error.
32
        return DB::table('migrations')->get()->pluck('migration');
33
    }
34
}
35