Skip to content

Commit 582714b

Browse files
authored
Merge pull request #26 from devaslanphp/master
Merge latest release to dev
2 parents c954e76 + 2cea8b8 commit 582714b

20 files changed

Lines changed: 850 additions & 375 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
110110
- PR #13 made by @mihaisolomon
111111
- **Release 1.1.7**
112112
- Ticket attachments
113+
- **Release 1.1.8**
114+
- Time logged activities #25 PR integration
115+
- #19 by @mihaisolomon :
116+
- Add new resource `Activity` to referential
117+
- Add `Activity` to ticket time logging
118+
- Add `Activity` column to Excel exportation
113119

114120
## Support us
115121

app/Exports/ProjectHoursExport.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function headings(): array
2525
'User',
2626
'Time',
2727
'Hours',
28+
'Activity',
2829
'Date',
2930
];
3031
}
@@ -45,6 +46,7 @@ public function collection()
4546
'user' => $item->user->name,
4647
'time' => $item->forHumans,
4748
'hours' => number_format($item->value, 2, ',', ' '),
49+
'activity' => $item->activity ? $item->activity->name : '-',
4850
'date' => $item->created_at->format(__('Y-m-d g:i A')),
4951
]))
5052
);

app/Exports/TicketHoursExport.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function headings(): array
2424
'User',
2525
'Time',
2626
'Hours',
27+
'Activity',
2728
'Date',
2829
'Comment',
2930
];
@@ -41,6 +42,7 @@ public function collection()
4142
'user' => $item->user->name,
4243
'time' => $item->forHumans,
4344
'hours' => number_format($item->value, 2, ',', ' '),
45+
'activity' => $item->activity ? $item->activity->name : '-',
4446
'date' => $item->created_at->format(__('Y-m-d g:i A')),
4547
'comment' => $item->comment
4648
]);
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace App\Filament\Resources;
4+
5+
use App\Filament\Resources\ActivityResource\Pages;
6+
use App\Filament\Resources\ActivityResource\RelationManagers;
7+
use App\Models\Activity;
8+
use Filament\Forms;
9+
use Filament\Resources\Form;
10+
use Filament\Resources\Resource;
11+
use Filament\Resources\Table;
12+
use Filament\Tables;
13+
14+
class ActivityResource extends Resource
15+
{
16+
protected static ?string $model = Activity::class;
17+
18+
protected static ?string $navigationIcon = 'heroicon-o-clipboard';
19+
20+
protected static ?int $navigationSort = 1;
21+
22+
protected static function getNavigationLabel(): string
23+
{
24+
return __('Activities');
25+
}
26+
27+
public static function getPluralLabel(): ?string
28+
{
29+
return static::getNavigationLabel();
30+
}
31+
32+
protected static function getNavigationGroup(): ?string
33+
{
34+
return __('Referential');
35+
}
36+
37+
public static function form(Form $form): Form
38+
{
39+
return $form
40+
->schema([
41+
Forms\Components\Card::make()
42+
->schema([
43+
Forms\Components\Grid::make()
44+
->schema([
45+
Forms\Components\TextInput::make('name')
46+
->label(__('Activity name'))
47+
->required()
48+
->maxLength(255),
49+
50+
Forms\Components\RichEditor::make('description')
51+
->label(__('Description'))
52+
->required()
53+
->columnSpan(2),
54+
55+
])
56+
])
57+
]);
58+
}
59+
60+
public static function table(Table $table): Table
61+
{
62+
return $table
63+
->columns([
64+
Tables\Columns\TextColumn::make('name')
65+
->label(__('Activity name'))
66+
->sortable()
67+
->searchable(),
68+
69+
Tables\Columns\TextColumn::make('created_at')
70+
->label(__('Created at'))
71+
->dateTime()
72+
->sortable()
73+
->searchable(),
74+
])
75+
->filters([
76+
//
77+
])
78+
->actions([
79+
Tables\Actions\ViewAction::make(),
80+
Tables\Actions\EditAction::make(),
81+
])
82+
->bulkActions([
83+
Tables\Actions\DeleteBulkAction::make(),
84+
])
85+
->defaultSort('id');
86+
}
87+
88+
public static function getRelations(): array
89+
{
90+
return [
91+
//
92+
];
93+
}
94+
95+
public static function getPages(): array
96+
{
97+
return [
98+
'index' => Pages\ListActivities::route('/'),
99+
'create' => Pages\CreateActivity::route('/create'),
100+
'view' => Pages\ViewActivity::route('/{record}'),
101+
'edit' => Pages\EditActivity::route('/{record}/edit'),
102+
];
103+
}
104+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\ActivityResource\Pages;
4+
5+
use App\Filament\Resources\ActivityResource;
6+
use Filament\Resources\Pages\CreateRecord;
7+
8+
class CreateActivity extends CreateRecord
9+
{
10+
protected static string $resource = ActivityResource::class;
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\ActivityResource\Pages;
4+
5+
use App\Filament\Resources\ActivityResource;
6+
use Filament\Pages\Actions;
7+
use Filament\Resources\Pages\EditRecord;
8+
9+
class EditActivity extends EditRecord
10+
{
11+
protected static string $resource = ActivityResource::class;
12+
13+
protected function getActions(): array
14+
{
15+
return [
16+
Actions\ViewAction::make(),
17+
Actions\DeleteAction::make(),
18+
];
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\ActivityResource\Pages;
4+
5+
use App\Filament\Resources\ActivityResource;
6+
use Filament\Pages\Actions;
7+
use Filament\Resources\Pages\ListRecords;
8+
9+
class ListActivities extends ListRecords
10+
{
11+
protected static string $resource = ActivityResource::class;
12+
13+
protected function getActions(): array
14+
{
15+
return [
16+
Actions\CreateAction::make(),
17+
];
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\ActivityResource\Pages;
4+
5+
use App\Filament\Resources\ActivityResource;
6+
use Filament\Pages\Actions;
7+
use Filament\Resources\Pages\ViewRecord;
8+
9+
class ViewActivity extends ViewRecord
10+
{
11+
protected static string $resource = ActivityResource::class;
12+
13+
protected function getActions(): array
14+
{
15+
return [
16+
Actions\EditAction::make(),
17+
];
18+
}
19+
}

app/Filament/Resources/TicketResource/Pages/ViewTicket.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
use App\Exports\TicketHoursExport;
66
use App\Filament\Resources\TicketResource;
7+
use App\Models\Activity;
78
use App\Models\TicketComment;
89
use App\Models\TicketHour;
910
use App\Models\TicketSubscriber;
1011
use Filament\Forms\Components\RichEditor;
12+
use Filament\Forms\Components\Select;
1113
use Filament\Forms\Components\Textarea;
1214
use Filament\Forms\Components\TextInput;
1315
use Filament\Forms\Components\TimePicker;
@@ -99,7 +101,13 @@ protected function getActions(): array
99101
->label(__('Time to log'))
100102
->numeric()
101103
->required(),
102-
104+
Select::make('activity_id')
105+
->label(__('Activity'))
106+
->searchable()
107+
->reactive()
108+
->options(function ($get, $set) {
109+
return Activity::all()->pluck('name', 'id')->toArray();
110+
}),
103111
Textarea::make('comment')
104112
->label(__('Comment'))
105113
->rows(3),
@@ -109,6 +117,7 @@ protected function getActions(): array
109117
$comment = $data['comment'];
110118
TicketHour::create([
111119
'ticket_id' => $this->record->id,
120+
'activity_id' => $data['activity_id'],
112121
'user_id' => auth()->user()->id,
113122
'value' => $value,
114123
'comment' => $comment

app/Models/Activity.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\SoftDeletes;
8+
9+
class Activity extends Model
10+
{
11+
use HasFactory, SoftDeletes;
12+
13+
protected $fillable = [
14+
'name',
15+
'description'
16+
];
17+
}

0 commit comments

Comments
 (0)