Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit e570cdb

Browse files
committed
Lots of changes and fixes
1 parent df50317 commit e570cdb

Some content is hidden

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

60 files changed

+15607
-373
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use App\LdapDomain;
6+
use App\Ldap\Transformers\AttributeTransformer;
7+
8+
class DomainObjectAttributesController
9+
{
10+
/**
11+
* Returns an HTML partial of the objects attributes.
12+
*
13+
* @param LdapDomain $domain
14+
* @param string $objectId
15+
*
16+
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
17+
*/
18+
public function index(LdapDomain $domain, $objectId)
19+
{
20+
$object = $domain->objects()->withTrashed()->findOrFail($objectId);
21+
22+
$attributes = (new AttributeTransformer($object->values))->transform();
23+
24+
return view('domains.objects.attributes.table', compact('domain', 'object', 'attributes'));
25+
}
26+
}

app/Http/Controllers/Api/NotificationMarkController.php

-19
This file was deleted.

app/Http/Controllers/Api/NotificationsController.php

+10
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,14 @@ public function index(Request $request)
3838
'Cache-Control' => 'no-cache',
3939
]);
4040
}
41+
42+
public function markRead()
43+
{
44+
45+
}
46+
47+
public function markUnread()
48+
{
49+
50+
}
4151
}

app/Http/Controllers/DomainNotifiersController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ public function create(LdapDomain $domain, LdapNotifier $notifier)
4747
* @param LdapNotifierRequest $request
4848
* @param LdapDomain $domain
4949
*
50-
* @return \Illuminate\Http\RedirectResponse
50+
* @return \Illuminate\Http\Response
5151
*/
5252
public function store(LdapNotifierRequest $request, LdapDomain $domain)
5353
{
54-
$request->persist(new LdapNotifier(), $domain);
54+
$notifier = $domain->notifiers()->make();
5555

56-
flash()->success('Added domain notifier');
56+
$request->persist($notifier);
5757

58-
return redirect()->route('domains.notifiers.index', $domain);
58+
return response()->turbolinks(route('domains.notifiers.index', [$domain, $notifier]));
5959
}
6060

6161
/**

app/Http/Controllers/DomainScansController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DomainScansController extends Controller
1515
*/
1616
public function index(LdapDomain $domain)
1717
{
18-
$scans = $domain->scans()->latest()->paginate(25);
18+
$scans = $domain->scans()->latest()->paginate(10);
1919

2020
return view('domains.scans.index', compact('domain', 'scans'));
2121
}

app/Http/Controllers/DomainNotifierConditionsController.php app/Http/Controllers/NotifierConditionsController.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@
33
namespace App\Http\Controllers;
44

55
use App\LdapDomain;
6+
use App\LdapNotifier;
67
use App\LdapNotifierCondition;
78
use App\Http\Requests\LdapNotifierConditionRequest;
89

9-
class DomainNotifierConditionsController extends Controller
10+
class NotifierConditionsController extends Controller
1011
{
1112
/**
1213
* Create a new notifier condition.
1314
*
1415
* @param LdapNotifierConditionRequest $request
15-
* @param LdapDomain $domain
16-
* @param string $notifierId
16+
* @param LdapNotifier $notifier
1717
*
1818
* @return mixed
1919
*/
20-
public function store(LdapNotifierConditionRequest $request, LdapDomain $domain, $notifierId)
20+
public function store(LdapNotifierConditionRequest $request, LdapNotifier $notifier)
2121
{
22-
$notifier = $domain->notifiers()->findOrFail($notifierId);
23-
2422
$request->persist($notifier, new LdapNotifierCondition());
2523

2624
return redirect()->turbolinks(route('domain.notifiers.edit', [$domain, $notifier]));

app/Http/Requests/LdapNotifierRequest.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Http\Requests;
44

5-
use App\LdapDomain;
65
use App\LdapNotifier;
76
use Illuminate\Foundation\Http\FormRequest;
87

@@ -25,15 +24,13 @@ public function rules()
2524
/**
2625
* Save an LDAP notifier.
2726
*
28-
* @param LdapDomain $domain
2927
* @param LdapNotifier $notifier
3028
*
3129
* @return LdapNotifier
3230
*/
33-
public function persist(LdapDomain $domain, LdapNotifier $notifier)
31+
public function persist(LdapNotifier $notifier)
3432
{
3533
if (!$notifier->exists) {
36-
$notifier->notifiable()->associate($domain);
3734
$notifier->creator()->associate($this->user());
3835
}
3936

app/Http/Resources/Notifications.php app/Http/Resources/LdapDomain.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Http\Resources\Json\JsonResource;
66

7-
class Notifications extends JsonResource
7+
class LdapDomain extends JsonResource
88
{
99
/**
1010
* Transform the resource into an array.
@@ -17,6 +17,10 @@ public function toArray($request)
1717
{
1818
return [
1919
'id' => $this->id,
20+
'name' => $this->name,
21+
'slug' => $this->slug,
22+
'base_dn' => $this->base_dn,
23+
'type' => $this->type,
2024
];
2125
}
2226
}

app/Http/Resources/LdapNotifier.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Http\Resources;
4+
5+
use Illuminate\Http\Resources\Json\JsonResource;
6+
7+
class LdapNotifier extends JsonResource
8+
{
9+
/**
10+
* Transform the resource into an array.
11+
*
12+
* @param \Illuminate\Http\Request $request
13+
*
14+
* @return array
15+
*/
16+
public function toArray($request)
17+
{
18+
return [
19+
'id' => $this->id,
20+
'name' => $this->name,
21+
'notifiable_name' => $this->notifiable_name,
22+
'notifiable_id' => $this->notifiable_id,
23+
'notifiable_type' => $this->notifiable_type,
24+
'all_users' => $this->all_users,
25+
];
26+
}
27+
}

app/Http/Resources/LdapObject.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Resources;
4+
5+
use Illuminate\Http\Resources\Json\JsonResource;
6+
7+
class LdapObject extends JsonResource
8+
{
9+
/**
10+
* Transform the resource into an array.
11+
*
12+
* @param \Illuminate\Http\Request $request
13+
*
14+
* @return array
15+
*/
16+
public function toArray($request)
17+
{
18+
return [
19+
'id' => $this->id,
20+
'domain_id' => $this->domain_id,
21+
'parent_id' => $this->parent_id,
22+
'guid' => $this->guid,
23+
'name' => $this->name,
24+
'type' => $this->type,
25+
'icon' => $this->icon,
26+
'values' => $this->values,
27+
'domain' => LdapDomain::make($this->domain),
28+
];
29+
}
30+
}

app/Http/View/Composers/DomainLayoutComposer.php

-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ public function compose(View $view)
2727
})->count()
2828
]];
2929

30-
if ($objectId = request()->object) {
31-
$object = $domain->objects()->withTrashed()->findOrFail($objectId);
32-
33-
$data['counts']['object'] = [
34-
'attributes' => count($object->values),
35-
'changes' => $object->changes()->count(),
36-
];
37-
}
38-
3930
$view->with($data);
4031
}
4132
}

app/Http/View/Composers/NotifierFormComposer.php app/Http/View/Composers/NotifierConditionFormComposer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use App\LdapNotifierCondition;
66
use Illuminate\Contracts\View\View;
77

8-
class NotifierFormComposer
8+
class NotifierConditionFormComposer
99
{
1010
/**
1111
* Bind data to the view.

app/LdapDomain.php

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ class LdapDomain extends Model
3737
'follow_referrals' => 'bool',
3838
];
3939

40+
/**
41+
* The attributes that should be hidden for serialization.
42+
*
43+
* @var array
44+
*/
45+
protected $hidden = [
46+
'username',
47+
'password',
48+
'token',
49+
];
50+
4051
/**
4152
* The attributes that should be mutated to dates.
4253
*

app/LdapNotifier.php

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static function boot()
4040

4141
static::deleting(function (LdapNotifier $notifier) {
4242
$notifier->conditions()->delete();
43+
$notifier->logs()->delete();
4344
});
4445
}
4546

@@ -73,6 +74,16 @@ public function logs()
7374
return $this->hasMany(LdapNotifierLog::class, 'notifier_id');
7475
}
7576

77+
/**
78+
* The belongsTo many users relationship.
79+
*
80+
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
81+
*/
82+
public function users()
83+
{
84+
return $this->belongsToMany(User::class, 'ldap_notifier_users');
85+
}
86+
7687
/**
7788
* The owning notifiable models relationship.
7889
*

app/LdapObject.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
namespace App;
44

55
use Illuminate\Database\Eloquent\Model;
6-
use Illuminate\Notifications\Notifiable;
76
use Illuminate\Database\Eloquent\SoftDeletes;
87

98
class LdapObject extends Model
109
{
11-
use Notifiable, SoftDeletes;
10+
use SoftDeletes;
1211

1312
/**
1413
* The attributes that are mass assignable.
@@ -29,6 +28,13 @@ class LdapObject extends Model
2928
*/
3029
protected $casts = ['values' => 'array'];
3130

31+
/**
32+
* The accessors to append to the model's array form.
33+
*
34+
* @var array
35+
*/
36+
protected $appends = ['icon'];
37+
3238
/**
3339
* The "booting" method of the model.
3440
*
@@ -45,7 +51,6 @@ public static function boot()
4551
if ($object->isForceDeleting()) {
4652
$object->changes()->delete();
4753
$object->notifiers()->delete();
48-
$object->notifications()->delete();
4954
}
5055
});
5156
}

app/Notifications.php

-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App;
44

55
use Illuminate\Notifications\DatabaseNotification;
6-
use App\Http\Resources\Notifications as NotificationResource;
76

87
class Notifications
98
{
@@ -33,14 +32,4 @@ public function get()
3332
->limit(10)
3433
->get();
3534
}
36-
37-
/**
38-
* Get the users notifications as a resource.
39-
*
40-
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
41-
*/
42-
public function resource()
43-
{
44-
return NotificationResource::collection($this->get());
45-
}
4635
}

0 commit comments

Comments
 (0)