Skip to content

Commit 0e38cd8

Browse files
committed
Merge PR25 to Master
1 parent 72fac8d commit 0e38cd8

File tree

10 files changed

+562
-394
lines changed

10 files changed

+562
-394
lines changed

app/Filament/Resources/ActivityResource/Pages/CreateActivity.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@
33
namespace App\Filament\Resources\ActivityResource\Pages;
44

55
use App\Filament\Resources\ActivityResource;
6-
use App\Models\TicketType;
76
use Filament\Resources\Pages\CreateRecord;
87

98
class CreateActivity extends CreateRecord
109
{
1110
protected static string $resource = ActivityResource::class;
12-
13-
protected function afterCreate(): void
14-
{
15-
if ($this->record->is_default) {
16-
TicketType::where('id', '<>', $this->record->id)
17-
->where('is_default', true)
18-
->update(['is_default' => false]);
19-
}
20-
}
2111
}

app/Filament/Resources/ActivityResource/Pages/EditActivity.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Filament\Resources\ActivityResource\Pages;
44

55
use App\Filament\Resources\ActivityResource;
6-
use App\Models\TicketStatus;
76
use Filament\Pages\Actions;
87
use Filament\Resources\Pages\EditRecord;
98

@@ -18,13 +17,4 @@ protected function getActions(): array
1817
Actions\DeleteAction::make(),
1918
];
2019
}
21-
22-
protected function afterSave(): void
23-
{
24-
if ($this->record->is_default) {
25-
TicketStatus::where('id', '<>', $this->record->id)
26-
->where('is_default', true)
27-
->update(['is_default' => false]);
28-
}
29-
}
3020
}

app/Models/Activity.php

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

55
use Illuminate\Database\Eloquent\Factories\HasFactory;
66
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\SoftDeletes;
78

89
class Activity extends Model
910
{
10-
use HasFactory;
11+
use HasFactory, SoftDeletes;
1112

1213
protected $fillable = [
1314
'name',

app/Policies/ActivityPolicy.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
namespace App\Policies;
4+
5+
use App\Models\Activity;
6+
use App\Models\User;
7+
use Illuminate\Auth\Access\HandlesAuthorization;
8+
9+
class ActivityPolicy
10+
{
11+
use HandlesAuthorization;
12+
13+
/**
14+
* Determine whether the user can view any models.
15+
*
16+
* @param \App\Models\User $user
17+
* @return \Illuminate\Auth\Access\Response|bool
18+
*/
19+
public function viewAny(User $user)
20+
{
21+
return $user->can('List activities');
22+
}
23+
24+
/**
25+
* Determine whether the user can view the model.
26+
*
27+
* @param \App\Models\User $user
28+
* @param \App\Models\Activity $activity
29+
* @return \Illuminate\Auth\Access\Response|bool
30+
*/
31+
public function view(User $user, Activity $activity)
32+
{
33+
return $user->can('View activity');
34+
}
35+
36+
/**
37+
* Determine whether the user can create models.
38+
*
39+
* @param \App\Models\User $user
40+
* @return \Illuminate\Auth\Access\Response|bool
41+
*/
42+
public function create(User $user)
43+
{
44+
return $user->can('Create activity');
45+
}
46+
47+
/**
48+
* Determine whether the user can update the model.
49+
*
50+
* @param \App\Models\User $user
51+
* @param \App\Models\Activity $activity
52+
* @return \Illuminate\Auth\Access\Response|bool
53+
*/
54+
public function update(User $user, Activity $activity)
55+
{
56+
return $user->can('Update activity');
57+
}
58+
59+
/**
60+
* Determine whether the user can delete the model.
61+
*
62+
* @param \App\Models\User $user
63+
* @param \App\Models\Activity $activity
64+
* @return \Illuminate\Auth\Access\Response|bool
65+
*/
66+
public function delete(User $user, Activity $activity)
67+
{
68+
return $user->can('Delete activity');
69+
}
70+
71+
/**
72+
* Determine whether the user can restore the model.
73+
*
74+
* @param \App\Models\User $user
75+
* @param \App\Models\Activity $activity
76+
* @return \Illuminate\Auth\Access\Response|bool
77+
*/
78+
public function restore(User $user, Activity $activity)
79+
{
80+
//
81+
}
82+
83+
/**
84+
* Determine whether the user can permanently delete the model.
85+
*
86+
* @param \App\Models\User $user
87+
* @param \App\Models\Activity $activity
88+
* @return \Illuminate\Auth\Access\Response|bool
89+
*/
90+
public function forceDelete(User $user, Activity $activity)
91+
{
92+
//
93+
}
94+
}

database/migrations/2023_01_09_113159_create_activities_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function up()
2020
$table->mediumText('description');
2121

2222
$table->timestamps();
23+
$table->softDeletes();
2324
});
2425
}
2526

database/referential.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ INSERT INTO `ticket_types` (`id`, `name`, `icon`, `color`, `is_default`, `delete
1414
(2, 'Evolution', 'heroicon-o-clipboard-list', '#008000', 0, NULL, '2022-11-14 12:06:56', '2022-11-14 12:06:56'),
1515
(3, 'Bug', 'heroicon-o-x', '#ff0000', 0, NULL, '2022-11-14 12:06:56', '2022-11-14 12:06:56');
1616

17+
18+
INSERT INTO `activities` (`id`, `name`, `description`, `created_at`, `updated_at`, `deleted_at`) VALUES
19+
(1, 'Programming', 'Programming related activities', '2023-01-09 13:10:52', '2023-01-09 13:10:52', NULL),
20+
(2, 'Testing', 'Testing related activities', '2023-01-09 13:10:52', '2023-01-09 13:10:52', NULL),
21+
(3, 'Learning', 'Activities related to learning and training', '2023-01-09 13:10:52', '2023-01-09 13:10:52', NULL),
22+
(4, 'Research', 'Activities related to research', '2023-01-09 13:10:52', '2023-01-09 13:10:52', NULL),
23+
(5, 'Other', 'Other activities', '2023-01-09 13:10:52', '2023-01-09 13:10:52', NULL);
24+
1725
ALTER TABLE `ticket_priorities`
1826
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
1927

2028
ALTER TABLE `ticket_statuses`
2129
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
30+
2231
ALTER TABLE `ticket_types`
2332
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
33+
34+
ALTER TABLE `activities`
35+
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

0 commit comments

Comments
 (0)