Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 244 | Revision 260 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
233 lars 1
<?php
2
 
3
namespace App\Console\Commands;
4
 
245 lars 5
use App\Models\Directory;
233 lars 6
use Illuminate\Console\Command;
236 lars 7
use Illuminate\Support\Facades\DB;
233 lars 8
 
9
class convertDB extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
235 lars 16
    protected $signature = 'command:convertDB';
233 lars 17
 
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
235 lars 23
    protected $description = 'Converts the old webanOS-DB to laravel';
233 lars 24
 
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return int
29
     */
30
    public function handle()
31
    {
234 lars 32
        $sql = '
33
            SELECT
34
                *
35
            FROM
36
                directory
37
        ';
237 lars 38
        $dirs = DB::connection('old')->select($sql);
238 lars 39
        foreach ($dirs as $row)
40
        {
41
            //var_dump($row);
245 lars 42
            Directory::factory()->createQuietly([
239 lars 43
                "id"           => $row->ID,
44
                "directory_id" => $row->Father,
240 lars 45
                "name"         => $row->Name,
239 lars 46
                "status"       => $row->status,
241 lars 47
                "kennung"      => $row->Kennung,
242 lars 48
                "description"  => $row->Beschreibung,
239 lars 49
                "short_line_1" => $row->short_line_1,
50
                "url"          => $row->url,
243 lars 51
                "created_at"   => $row->erstellt_am,
52
                "updated_at"   => $row->letzte_Aenderung_am,
238 lars 53
            ]);
234 lars 54
        }
233 lars 55
    }
56
}