Skip to content

Commit c2ff23b

Browse files
committed
made requested changes
1 parent 207f912 commit c2ff23b

File tree

9 files changed

+340
-3
lines changed

9 files changed

+340
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ resume-monitoring.sh
4545
.envault.json
4646
.phpunit.result.cache
4747
/docs/_build/
48+
.DS_Store

app/Console/Commands/ImportAllModels.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ public function handle(): int
5757
'model' => Event::class,
5858
]);
5959

60+
$this->call('scout:import', [
61+
'model' => Sponsor::class,
62+
]);
63+
64+
$this->call('scout:import', [
65+
'model' => SponsorDomain::class,
66+
]);
67+
68+
$this->call('scout:import', [
69+
'model' => SponsorUser::class,
70+
]);
71+
6072
$this->call('scout:import', [
6173
'model' => Team::class,
6274
]);

app/Nova/SponsorDomain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SponsorDomain extends Resource
3030
*
3131
* @var string
3232
*/
33-
public static $title = 'name';
33+
public static $title = 'domain_name';
3434

3535
/**
3636
* The logical group associated with the resource.

app/Nova/SponsorUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SponsorUser extends Resource
3131
*
3232
* @var string
3333
*/
34-
public static $title = 'name';
34+
public static $title = 'email';
3535

3636
/**
3737
* The logical group associated with the resource.
@@ -76,7 +76,7 @@ public function fields(NovaRequest $request): array
7676
->rules('required')
7777
->sortable(),
7878
Text::make('Email', 'email')
79-
->rules('required', 'email', 'max:255', new SponsorUserValidEmail())
79+
->rules('required', 'email:rfc,strict,dns,spoof', 'max:255', new SponsorUserValidEmail())
8080
->sortable(),
8181
];
8282
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Policies;
6+
7+
use App\Models\SponsorDomain;
8+
use App\Models\User;
9+
use Illuminate\Auth\Access\HandlesAuthorization;
10+
11+
class SponsorDomainPolicy
12+
{
13+
use HandlesAuthorization;
14+
15+
/**
16+
* Determine whether the user can view any models.
17+
*/
18+
public function viewAny(User $user): bool
19+
{
20+
return $user->can('view-sponsors');
21+
}
22+
23+
/**
24+
* Determine whether the user can view the model.
25+
*/
26+
public function view(User $user, SponsorDomain $sponsorDomain): bool
27+
{
28+
return $user->can('view-sponsors');
29+
}
30+
31+
/**
32+
* Determine whether the user can create models.
33+
*/
34+
public function create(User $user): bool
35+
{
36+
return $user->can('manage-sponsors');
37+
}
38+
39+
/**
40+
* Determine whether the user can update the model.
41+
*/
42+
public function update(User $user, SponsorDomain $sponsorDomain): bool
43+
{
44+
return $user->can('manage-sponsors');
45+
}
46+
47+
/**
48+
* Determine whether the user can delete the model.
49+
*/
50+
public function delete(User $user, SponsorDomain $sponsorDomain): bool
51+
{
52+
return $user->can('manage-sponsors');
53+
}
54+
55+
/**
56+
* Determine whether the user can restore the model.
57+
*/
58+
public function restore(User $user, SponsorDomain $sponsorDomain): bool
59+
{
60+
return $user->can('manage-sponsors');
61+
}
62+
63+
/**
64+
* Determine whether the user can permanently delete the model.
65+
*/
66+
public function forceDelete(User $user, SponsorDomain $sponsorDomain): bool
67+
{
68+
return false;
69+
}
70+
71+
public function replicate(User $user, SponsorDomain $sponsorDomain): bool
72+
{
73+
return false;
74+
}
75+
}

app/Policies/SponsorPolicy.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Policies;
6+
7+
use App\Models\Sponsor;
8+
use App\Models\User;
9+
use Illuminate\Auth\Access\HandlesAuthorization;
10+
11+
class SponsorPolicy
12+
{
13+
use HandlesAuthorization;
14+
15+
/**
16+
* Determine whether the user can view any models.
17+
*/
18+
public function viewAny(User $user): bool
19+
{
20+
return $user->can('view-sponsors');
21+
}
22+
23+
/**
24+
* Determine whether the user can view the model.
25+
*/
26+
public function view(User $user, Sponsor $sponsor): bool
27+
{
28+
return $user->can('view-sponsors');
29+
}
30+
31+
/**
32+
* Determine whether the user can create models.
33+
*/
34+
public function create(User $user): bool
35+
{
36+
return $user->can('manage-sponsors');
37+
}
38+
39+
/**
40+
* Determine whether the user can update the model.
41+
*/
42+
public function update(User $user, Sponsor $sponsor): bool
43+
{
44+
return $user->can('manage-sponsors');
45+
}
46+
47+
/**
48+
* Determine whether the user can delete the model.
49+
*/
50+
public function delete(User $user, Sponsor $sponsor): bool
51+
{
52+
return $user->can('manage-sponsors');
53+
}
54+
55+
/**
56+
* Determine whether the user can restore the model.
57+
*/
58+
public function restore(User $user, Sponsor $sponsor): bool
59+
{
60+
return $user->can('manage-sponsors');
61+
}
62+
63+
/**
64+
* Determine whether the user can permanently delete the model.
65+
*/
66+
public function forceDelete(User $user, Sponsor $sponsor): bool
67+
{
68+
return false;
69+
}
70+
71+
public function replicate(User $user, Sponsor $sponsor): bool
72+
{
73+
return false;
74+
}
75+
}

app/Policies/SponsorUserPolicy.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Policies;
6+
7+
use App\Models\SponsorUser;
8+
use App\Models\User;
9+
use Illuminate\Auth\Access\HandlesAuthorization;
10+
11+
class SponsorUserPolicy
12+
{
13+
use HandlesAuthorization;
14+
15+
/**
16+
* Determine whether the user can view any models.
17+
*/
18+
public function viewAny(User $user): bool
19+
{
20+
return $user->can('view-sponsors');
21+
}
22+
23+
/**
24+
* Determine whether the user can view the model.
25+
*/
26+
public function view(User $user, SponsorUser $sponsorUser): bool
27+
{
28+
return $user->can('view-sponsors');
29+
}
30+
31+
/**
32+
* Determine whether the user can create models.
33+
*/
34+
public function create(User $user): bool
35+
{
36+
return $user->can('manage-sponsors');
37+
}
38+
39+
/**
40+
* Determine whether the user can update the model.
41+
*/
42+
public function update(User $user, SponsorUser $sponsorUser): bool
43+
{
44+
return $user->can('manage-sponsors');
45+
}
46+
47+
/**
48+
* Determine whether the user can delete the model.
49+
*/
50+
public function delete(User $user, SponsorUser $sponsorUser): bool
51+
{
52+
return $user->can('manage-sponsors');
53+
}
54+
55+
/**
56+
* Determine whether the user can restore the model.
57+
*/
58+
public function restore(User $user, SponsorUser $sponsorUser): bool
59+
{
60+
return $user->can('manage-sponsors');
61+
}
62+
63+
/**
64+
* Determine whether the user can permanently delete the model.
65+
*/
66+
public function forceDelete(User $user, SponsorUser $sponsorUser): bool
67+
{
68+
return false;
69+
}
70+
71+
public function replicate(User $user, SponsorUser $sponsorUser): bool
72+
{
73+
return false;
74+
}
75+
}

config/scout.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,66 @@
233233
'disableOnNumbers' => true,
234234
],
235235
],
236+
\App\Models\Sponsor::class => [
237+
'displayedAttributes' => [
238+
'id',
239+
],
240+
'searchableAttributes' => [
241+
'name',
242+
],
243+
'rankingRules' => [
244+
'words',
245+
'typo',
246+
'proximity',
247+
'attribute',
248+
'sort',
249+
'exactness',
250+
'end_date_unix:desc',
251+
],
252+
'typoTolerance' => [
253+
'disableOnNumbers' => true,
254+
],
255+
],
256+
\App\Models\SponsorDomain::class => [
257+
'displayedAttributes' => [
258+
'id',
259+
],
260+
'searchableAttributes' => [
261+
'domain_name',
262+
],
263+
'rankingRules' => [
264+
'words',
265+
'typo',
266+
'proximity',
267+
'attribute',
268+
'sort',
269+
'exactness',
270+
'end_date_unix:desc',
271+
],
272+
'typoTolerance' => [
273+
'disableOnNumbers' => true,
274+
],
275+
],
276+
\App\Models\SponsorUser::class => [
277+
'displayedAttributes' => [
278+
'id',
279+
],
280+
'searchableAttributes' => [
281+
'email',
282+
],
283+
'rankingRules' => [
284+
'words',
285+
'typo',
286+
'proximity',
287+
'attribute',
288+
'sort',
289+
'exactness',
290+
'end_date_unix:desc',
291+
],
292+
'typoTolerance' => [
293+
'disableOnNumbers' => true,
294+
],
295+
],
236296
\App\Models\Team::class => [
237297
'displayedAttributes' => [
238298
'id',
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Illuminate\Database\Migrations\Migration;
6+
use Spatie\Permission\Models\Permission;
7+
use Spatie\Permission\Models\Role;
8+
9+
return new class extends Migration
10+
{
11+
/**
12+
* Run the migrations.
13+
*/
14+
public function up(): void
15+
{
16+
app()['cache']->forget('spatie.permission.cache');
17+
18+
$view = Permission::firstOrCreate(['name' => 'view-sponsors']);
19+
$manage = Permission::firstOrCreate(['name' => 'manage-sponsors']);
20+
21+
$officer = Role::firstOrCreate(['name' => 'officer']);
22+
$admin = Role::firstOrCreate(['name' => 'admin']);
23+
24+
$officer->givePermissionTo($manage);
25+
$admin->givePermissionTo($manage);
26+
$officer->givePermissionTo($view);
27+
$admin->givePermissionTo($view);
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*/
33+
public function down(): void
34+
{
35+
app()['cache']->forget('spatie.permission.cache');
36+
37+
Permission::where('name', 'approve-travel')->delete();
38+
}
39+
};

0 commit comments

Comments
 (0)