public function handle()
{
$name = $this->argument('name');
$ext = strpos($name, '.md') ? '' : '.md';
$filepath = storage_path('app/posts') . '/' . $name . $ext;
try {
$inputs = parseArticle($filepath);
$res = $this->post->getByColumn($inputs['slug'], 'slug');
if (is_null($res)) {
$this->post->store($inputs);
$this->info($name . ' parsed successfully!');
} else {
$this->post->update($inputs, $res->id);
$this->info($name . ' updated successfully!');
}
} catch (Exception $e) {
$this->error($name . ' parsed failed! Please check the syntax.', 10);
}
}