mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
29 lines
750 B
PHP
29 lines
750 B
PHP
<?php
|
|
declare(strict_types = 1);
|
|
namespace FireflyIII\Helpers\Csv\Converter;
|
|
|
|
use FireflyIII\Models\Category;
|
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
|
|
|
/**
|
|
* Class CategoryId
|
|
*
|
|
* @package FireflyIII\Helpers\Csv\Converter
|
|
*/
|
|
class CategoryId extends BasicConverter implements ConverterInterface
|
|
{
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function convert(): Category
|
|
{
|
|
/** @var CategoryRepositoryInterface $repository */
|
|
$repository = app(CategoryRepositoryInterface::class);
|
|
$value = isset($this->mapped[$this->index][$this->value]) ? $this->mapped[$this->index][$this->value] : $this->value;
|
|
$category = $repository->find($value);
|
|
|
|
return $category;
|
|
}
|
|
}
|