DONE: layout letter with letterhead and footer, notification for newly...
This commit is contained in:
@@ -20,7 +20,7 @@ trait HasDocuments
|
||||
*/
|
||||
public function documentsOfType($type)
|
||||
{
|
||||
return $this->documents()->where('document_type', $type);
|
||||
return $this->documents()->where('type', $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,15 +33,15 @@ trait HasDocuments
|
||||
|
||||
// Store file in a folder named after the model
|
||||
$folderName = strtolower(class_basename($this));
|
||||
$filePath = $file->storeAs("documents/{$folderName}", $fileName);
|
||||
$filePath = $file->storeAs("documents/{$folderName}", $fileName, Document::STORAGE_DISK);
|
||||
|
||||
// Create document record
|
||||
return $this->documents()->create([
|
||||
'document_name' => $file->getClientOriginalName(),
|
||||
'document_path' => $filePath,
|
||||
'name' => $file->getClientOriginalName(),
|
||||
'path' => $filePath,
|
||||
'file_size' => $file->getSize(),
|
||||
'mime_type' => $file->getClientMimeType(),
|
||||
'document_type' => $documentType,
|
||||
'type' => $documentType,
|
||||
'description' => $description,
|
||||
'uploaded_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Services\VisibilityService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
trait HasVisibility
|
||||
{
|
||||
/**
|
||||
* Get the visibility service instance
|
||||
*/
|
||||
protected function getVisibilityService(): VisibilityService
|
||||
{
|
||||
return app(VisibilityService::class);
|
||||
}
|
||||
|
||||
public function scopeVisibleTo(Builder $query, $user)
|
||||
{
|
||||
$includeUnitsWithoutFormation = property_exists($this, 'includeUnitsWithoutFormation')
|
||||
? (bool) $this->includeUnitsWithoutFormation
|
||||
: false;
|
||||
|
||||
// Check if model has a direct unit column
|
||||
$unitColumn = property_exists($this, 'unitColumn') ? $this->unitColumn : 'unit_id';
|
||||
|
||||
// Check if model has an indirect unit relationship
|
||||
$unitRelationship = property_exists($this, 'unitRelationship') ? $this->unitRelationship : null;
|
||||
|
||||
if ($unitRelationship) {
|
||||
return $this->getVisibilityService()->applyVisibilityToIndirectQuery(
|
||||
$query,
|
||||
$user,
|
||||
$unitRelationship,
|
||||
$includeUnitsWithoutFormation
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getVisibilityService()->applyVisibilityToQuery(
|
||||
$query,
|
||||
$user,
|
||||
$unitColumn,
|
||||
$includeUnitsWithoutFormation
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all units under the same government as the user's unit
|
||||
* Handles both direct government relationships and formation-government relationships
|
||||
* Priority: Direct government_id takes precedence over formation government
|
||||
*
|
||||
* @deprecated Use VisibilityService::getUnitsUnderGovernment() instead
|
||||
*/
|
||||
protected function getUnitsUnderGovernment($userUnit)
|
||||
{
|
||||
return $this->getVisibilityService()->getUnitsUnderGovernment($userUnit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user