You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
1.1 KiB

<?php
namespace App\Console\Commands;
use App\ImageRecord;
use Illuminate\Console\Command;
use App\Services\DirService;
class RecordDir extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'record:dir';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
$service = new DirService();
$list = $service->recursiveScan("/Users/shixuesen/Documents/sync/image");
foreach ($list["files"] as $file) {
$fileInfo = pathinfo($file);
$imageRecord = new ImageRecord();
$imageRecord->path = $fileInfo["dirname"];
$imageRecord->name = $fileInfo["filename"];
$imageRecord->type = 2;
$imageRecord->save();
}
}
}