Skip to content

Commit c43f5d1

Browse files
authored
Merge pull request #22 from devaslanphp/dev
Ticket attachments
2 parents 7d78c23 + c954e76 commit c43f5d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+478
-63
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
106106
- **Release 1.1.5**
107107
- Add comment field to ticket hours logging
108108
- **Release 1.1.6**
109-
- Edit ticket epic details
110-
- PR #13 made by @mihaisolomon
109+
- Edit ticket epic details
110+
- PR #13 made by @mihaisolomon
111+
- **Release 1.1.7**
112+
- Ticket attachments
111113

112114
## Support us
113115

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace App\Http\Livewire\Ticket;
4+
5+
use App\Models\Ticket;
6+
use Filament\Facades\Filament;
7+
use Filament\Forms\Components\FileUpload;
8+
use Filament\Forms\Concerns\InteractsWithForms;
9+
use Filament\Forms\Contracts\HasForms;
10+
use Illuminate\Database\Eloquent\Model;
11+
use Livewire\Component;
12+
13+
class Attachments extends Component implements HasForms
14+
{
15+
use InteractsWithForms;
16+
17+
public Ticket $ticket;
18+
19+
public function mount(): void
20+
{
21+
$this->form->fill([
22+
'attachments' => $this->ticket->attachments
23+
]);
24+
}
25+
26+
public function render()
27+
{
28+
return view('livewire.ticket.attachments');
29+
}
30+
31+
protected function getFormModel(): Model|string|null
32+
{
33+
return $this->ticket;
34+
}
35+
36+
protected function getFormSchema(): array
37+
{
38+
return [
39+
FileUpload::make('attachments')
40+
->label(__('Attachments'))
41+
->hint(__('Important: If a file has the same name, it will be replaced'))
42+
->helperText(__('Here you can attach all files needed for this ticket'))
43+
->multiple()
44+
->disablePreview()
45+
->enableReordering()
46+
->enableOpen()
47+
->preserveFilenames()
48+
->enableDownload()
49+
->directory(fn() => 'tickets/' . $this->ticket->code)
50+
];
51+
}
52+
53+
public function perform(): void
54+
{
55+
$data = $this->form->getState();
56+
$this->ticket->attachments = $data['attachments'];
57+
$this->ticket->save();
58+
$this->ticket->refresh();
59+
Filament::notify('success', __('Ticket attachments saved'));
60+
}
61+
}

app/Models/Ticket.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class Ticket extends Model
2020
protected $fillable = [
2121
'name', 'content', 'owner_id', 'responsible_id',
2222
'status_id', 'project_id', 'code', 'order', 'type_id',
23-
'priority_id', 'estimation', 'epic_id'
23+
'priority_id', 'estimation', 'epic_id', 'attachments',
24+
];
25+
26+
protected $casts = [
27+
'attachments' => 'array',
2428
];
2529

2630
public static function boot()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('tickets', function (Blueprint $table) {
16+
$table->longText('attachments')->nullable();
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
Schema::table('tickets', function (Blueprint $table) {
28+
$table->dropColumn('attachments');
29+
});
30+
}
31+
};

lang/ar.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@
189189
"Ticket successfully saved": "تم حفظ التذكرة بنجاح",
190190
"Parent epic": "ملحمة الوالدين",
191191
"Road Map chart is only available on large screen": "مخطط خريطة الطريق متاح فقط على الشاشة الكبيرة",
192-
"Comment": "تعليق"
192+
"Comment": "تعليق",
193+
"Attachments": "المرفقات",
194+
"Here you can attach all files needed for this ticket": "هنا يمكنك إرفاق جميع الملفات المطلوبة لهذه التذكرة",
195+
"Submit": "يُقدِّم",
196+
"Ticket attachments saved": "تم حفظ مرفقات التذاكر",
197+
"Important: If a file has the same name, it will be replaced": "هام: إذا كان الملف يحمل نفس الاسم ، فسيتم استبداله"
193198
}

lang/az.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@
189189
"Ticket successfully saved": "Bilet uğurla yadda saxlanıldı",
190190
"Parent epic": "Valideyn epik",
191191
"Road Map chart is only available on large screen": "Yol Xəritəsi diaqramı yalnız böyük ekranda mövcuddur",
192-
"Comment": "Şərh"
192+
"Comment": "Şərh",
193+
"Attachments": "Qoşmalar",
194+
"Here you can attach all files needed for this ticket": "Burada bu bilet üçün lazım olan bütün faylları əlavə edə bilərsiniz",
195+
"Submit": "təqdim",
196+
"Ticket attachments saved": "Bilet qoşmaları yadda saxlanıldı",
197+
"Important: If a file has the same name, it will be replaced": "Vacib: Əgər fayl eyni ada malikdirsə, o, dəyişdiriləcək"
193198
}

lang/be.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@
189189
"Ticket successfully saved": "Білет паспяхова захаваны",
190190
"Parent epic": "Бацькоўскі эпас",
191191
"Road Map chart is only available on large screen": "Дарожная карта даступная толькі на вялікім экране",
192-
"Comment": "Каментуйце"
192+
"Comment": "Каментуйце",
193+
"Attachments": "Дадаткі",
194+
"Here you can attach all files needed for this ticket": "Тут вы можаце далучыць усе файлы, неабходныя для гэтага білета",
195+
"Submit": "Падаць",
196+
"Ticket attachments saved": "Дадаткі да квіткоў захаваны",
197+
"Important: If a file has the same name, it will be replaced": "Важна: калі файл мае такую ​​ж назву, ён будзе заменены"
193198
}

lang/bg.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@
189189
"Ticket successfully saved": "Билетът е запазен успешно",
190190
"Parent epic": "Родителски епос",
191191
"Road Map chart is only available on large screen": "Диаграмата на пътната карта е достъпна само на голям екран",
192-
"Comment": "Коментирайте"
192+
"Comment": "Коментирайте",
193+
"Attachments": "Прикачени файлове",
194+
"Here you can attach all files needed for this ticket": "Тук можете да прикачите всички файлове, необходими за този билет",
195+
"Submit": "Изпращане",
196+
"Ticket attachments saved": "Прикачените файлове към билетите са запазени",
197+
"Important: If a file has the same name, it will be replaced": "Важно: Ако файл има същото име, той ще бъде заменен"
193198
}

lang/bn.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@
189189
"Ticket successfully saved": "টিকিট সফলভাবে সংরক্ষিত হয়েছে৷",
190190
"Parent epic": "অভিভাবক মহাকাব্য",
191191
"Road Map chart is only available on large screen": "রোড ম্যাপ চার্ট শুধুমাত্র বড় স্ক্রিনে উপলব্ধ",
192-
"Comment": "মন্তব্য করুন"
192+
"Comment": "মন্তব্য করুন",
193+
"Attachments": "সংযুক্তি",
194+
"Here you can attach all files needed for this ticket": "এখানে আপনি এই টিকিটের জন্য প্রয়োজনীয় সমস্ত ফাইল সংযুক্ত করতে পারেন",
195+
"Submit": "জমা দিন",
196+
"Ticket attachments saved": "টিকিট সংযুক্তি সংরক্ষিত",
197+
"Important: If a file has the same name, it will be replaced": "গুরুত্বপূর্ণ: যদি একটি ফাইলের নাম একই থাকে তবে এটি প্রতিস্থাপন করা হবে"
193198
}

lang/bs.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@
189189
"Ticket successfully saved": "Karta je uspješno sačuvana",
190190
"Parent epic": "Parent epic",
191191
"Road Map chart is only available on large screen": "Mapa puta je dostupna samo na velikom ekranu",
192-
"Comment": "Komentar"
192+
"Comment": "Komentar",
193+
"Attachments": "Prilozi",
194+
"Here you can attach all files needed for this ticket": "Ovdje možete priložiti sve datoteke potrebne za ovu kartu",
195+
"Submit": "Submit",
196+
"Ticket attachments saved": "Prilozi ulaznica su sačuvani",
197+
"Important: If a file has the same name, it will be replaced": "Važno: Ako datoteka ima isto ime, bit će zamijenjena"
193198
}

0 commit comments

Comments
 (0)