REFACTORING: move creating directories into repository

This commit is contained in:
Michal Kváček
2017-07-30 16:06:28 +02:00
parent f48c0cfac3
commit f876a08429
2 changed files with 29 additions and 11 deletions
@@ -31,22 +31,13 @@ class CreateDirectory implements Interaction
{
$data['parentDirectory'] = isset($data['parentDirectory']) ? $data['parentDirectory'] : null;
// todo this should probably go into validation, but we are not able to get $data in getValidationRules
// check if created folder does not exist in current directory
if ($this->repository->checkIfNameExists($data['name'], $data['parentDirectory'])) {
throw new SubdirectoryExistsInDirectory();
}
// todo use Directory::create() and rename columns/fields in request
// create new database entry
$directory = new Directory();
$directory->name = $data['name'];
$directory->parent_id = $data['parentDirectory'];
$directory->user_id = \Auth::user()->id;
$directory->description = $data['description'];
$directory->save();
return $directory;
return $this->repository->create($data);
}
/**