FIX: fix few minor bugs
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user