FIX: fix few minor bugs

This commit is contained in:
Michal Kváček
2017-02-09 23:42:07 +01:00
parent 9593b6502e
commit 0ba0d1c15d
4 changed files with 32 additions and 27 deletions
+22 -5
View File
@@ -3,15 +3,32 @@ namespace App\CMS\Repositories\FileManager;
use App\CMS\Helpers\RootDirectory;
use App\Models\FileManager\Directory as DirectoryModel;
use App\Models\FileManager\File;
class Directory
{
public function checkIfNameExists($name, $directoryId)
/**
* Checks if directory with given name does not exist in current directory
*
* @param $name
* @param $parentDirectoryId
* @param bool $ignoredId
*/
public function checkIfNameExists($name, $parentDirectoryId, $ignoredId = false)
{
return DirectoryModel::where('name', $name)
->where('parent_id', $directoryId)
->exists();
$exists = DirectoryModel::where('name', $name)
->where('parent_id', $parentDirectoryId);
if ($ignoredId !== false) {
$exists = $exists->where('id', '!=', $ignoredId);
}
return $exists->exists();
}
public function update(DirectoryModel $directory, $data) {
$directory->name = $data['name'];
$directory->description = $data['description'];
$directory->save();
}
/**