first commit

This commit is contained in:
Noor E Ilahi
2026-01-09 12:54:53 +05:30
commit 7ccf44f7da
1070 changed files with 113036 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Contracts;
abstract class AppReport
{
final public static function init(...$arguments): self
{
return new static(...$arguments);
}
abstract public function getReportId(): string;
abstract public function getLocalizedReportName(): string;
abstract public function store(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = []);
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Contracts;
use App\Models\Attachment;
use Illuminate\Database\Eloquent\Relations\MorphMany;
interface AttachmentAble
{
/**
* @return Attachment[]
*/
public function attachments();
public function attachmentsRelation(): MorphMany;
public function getProjectId(): int;
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Contracts;
use App\Models\Attachment;
use App\Models\Project;
use App\Models\Task;
use Illuminate\Http\UploadedFile;
interface AttachmentService
{
public function storeFile(UploadedFile $file, Attachment $attachment): string|false;
public function handleProjectChange(Task $parent): void;
public function moveAttachment(Attachment $attachment, $newProjectId): void;
public function deleteAttachment(Attachment $attachment): void;
public function deleteAttachments(array $attachmentsIds): void;
public function handleParentDeletion(AttachmentAble $parent): void;
public function handleProjectDeletion(Project $project): void;
public function fileExists(Attachment $attachment): bool;
public function attach(AttachmentAble $parent, array $idsToAttach);
public function getProjectPath(Project $project): string;
public function getPath(Attachment $attachment): string;
public function getFullPath(Attachment $attachment): string;
public function getHashAlgo(): string;
public function getHashSum(Attachment|string $attachment): false|string;
public function getMimeType(Attachment|string $attachment): false|string;
public function verifyHash(Attachment $attachment);
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Contracts;
use App\Jobs\GenerateScreenshotThumbnail;
use App\Models\TimeInterval;
use Image;
use Intervention\Image\Constraint;
use Storage;
abstract class ScreenshotService
{
protected const FILE_FORMAT = 'jpg';
public const PARENT_FOLDER = 'screenshots/';
public const THUMBS_FOLDER = 'thumbs/';
private const THUMB_WIDTH = 280;
private const QUALITY = 50;
/** Get screenshot path by interval */
abstract public function getScreenshotPath(TimeInterval|int $interval): string;
/** Get screenshot thumbnail path by interval */
abstract public function getThumbPath(TimeInterval|int $interval): string;
public function saveScreenshot($file, $timeInterval): void
{
if (!Storage::exists(self::PARENT_FOLDER)) {
Storage::makeDirectory(self::PARENT_FOLDER);
}
$path = is_string($file) ? $file : $file->path();
$image = Image::make($path);
Storage::put($this->getScreenshotPath($timeInterval), (string)$image->encode(self::FILE_FORMAT, self::QUALITY));
GenerateScreenshotThumbnail::dispatch($timeInterval);
}
public function createThumbnail(TimeInterval|int $timeInterval): void
{
if (!Storage::exists(self::PARENT_FOLDER . self::THUMBS_FOLDER)) {
Storage::makeDirectory(self::PARENT_FOLDER . self::THUMBS_FOLDER);
}
$image = Image::make(Storage::path($this->getScreenshotPath($timeInterval)));
$thumb = $image->resize(self::THUMB_WIDTH, null, fn(Constraint $constraint) => $constraint->aspectRatio());
Storage::put($this->getThumbPath($timeInterval), (string)$thumb->encode(self::FILE_FORMAT, self::QUALITY));
}
public function destroyScreenshot(TimeInterval|int $interval): void
{
Storage::delete($this->getScreenshotPath($interval));
Storage::delete($this->getThumbPath($interval));
}
public static function getFullPath(): string
{
$fileSystemPath = config('filesystems.default');
return storage_path(config("filesystems.disks.$fileSystemPath.root"));
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Contracts;
interface SettingsProvider
{
/**
* Get all module settings
*
* @return array
*/
public function all(): array;
/**
* Get the settings value by key
*
* @param string $key
* @param mixed|null $default
*
* @return mixed
*/
public function get(string $key, mixed $default = null): mixed;
/**
* Set the setting value
* A key value array can be passed as key
*
* @param string $key
* @param mixed|null $value
*
* @return void
*/
public function set(string $key, mixed $value = null): void;
/**
* Flushes module settings storage
*
* @return void
*/
public function flush(): void;
}