Skip to content

Ofoghe talaei #2226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('activity_files', function (Blueprint $table) {
$table->date('issue_date')->nullable();
$table->date('expiry_date')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('activity_files', function (Blueprint $table) {
$table->dropColumn(['issue_date', 'expiry_date']);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('persons', function (Blueprint $table) {
$table->string('partner_2')->nullable()->after('name'); // or appropriate type
$table->string('partner_3')->nullable()->after('partner_2');
$table->string('local_agent')->nullable()->after('partner_3');
sponsor
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('persons', function (Blueprint $table) {
$table->dropColumn(['partner_2', 'partner_3', 'local_agent']);
});
}
};
2 changes: 2 additions & 0 deletions packages/Webkul/Activity/src/Models/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class File extends Model implements FileContract
'name',
'path',
'activity_id',
'issue_date',
'expiry_date',
];

/**
Expand Down
29 changes: 16 additions & 13 deletions packages/Webkul/Activity/src/Repositories/ActivityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class ActivityRepository extends Repository
*/
public function __construct(
protected FileRepository $fileRepository,
Container $container
) {
Container $container
)
{
parent::__construct($container);
}

Expand All @@ -40,13 +41,15 @@ public function create(array $data)

if (isset($data['file'])) {
$this->fileRepository->create([
'name' => $data['name'] ?? $data['file']->getClientOriginalName(),
'path' => $data['file']->store('activities/'.$activity->id),
'issue_date' => $data['issue_date'] ?? null,
'expiry_date' => $data['expiry_date'] ?? null,
'name' => $data['name'] ?? $data['file']->getClientOriginalName(),
'path' => $data['file']->store('activities/' . $activity->id),
'activity_id' => $activity->id,
]);
}

if (! isset($data['participants'])) {
if (!isset($data['participants'])) {
return $activity;
}

Expand All @@ -68,8 +71,8 @@ public function create(array $data)
/**
* Update pipeline.
*
* @param int $id
* @param string $attribute
* @param int $id
* @param string $attribute
* @return \Webkul\Activity\Contracts\Activity
*/
public function update(array $data, $id, $attribute = 'id')
Expand Down Expand Up @@ -114,7 +117,7 @@ public function update(array $data, $id, $attribute = 'id')
}

/**
* @param string $dateRange
* @param string $dateRange
* @return mixed
*/
public function getActivities($dateRange)
Expand Down Expand Up @@ -143,10 +146,10 @@ public function getActivities($dateRange)
}

/**
* @param string $startFrom
* @param string $endFrom
* @param array $participants
* @param int $id
* @param string $startFrom
* @param string $endFrom
* @param array $participants
* @param int $id
* @return bool
*/
public function isDurationOverlapping($startFrom, $endFrom, $participants, $id)
Expand Down Expand Up @@ -176,7 +179,7 @@ public function isDurationOverlapping($startFrom, $endFrom, $participants, $id)
})
->groupBy('activities.id');

if (! is_null($id)) {
if (!is_null($id)) {
$queryBuilder->where('activities.id', '!=', $id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function prepareQueryBuilder(): Builder
$this->addFilter('id', 'attributes.id');
$this->addFilter('type', 'attributes.type');
$this->addFilter('attribute_type', 'attributes.is_user_defined');
$queryBuilder->orderBy('attributes.sort_order', 'asc');

return $queryBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ public function download(int $id): StreamedResponse
{
try {
$file = $this->fileRepository->findOrFail($id);
$extension = pathinfo($file->path, PATHINFO_EXTENSION);

if (!empty($file->name)) {
$customName = $file->name . '_' . $file->activity->title . '.' . $extension;
return Storage::download($file->path, $customName);
}

return Storage::download($file->path);
} catch (\Exception $exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ class ActivityFileResource extends JsonResource
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'path' => $this->path,
'url' => $this->url,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'id' => $this->id,
'name' => $this->name,
'path' => $this->path,
'url' => $this->url,
'issue_date' => $this->issue_date,
'expiry_date' => $this->expiry_date,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
Loading