-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite hfd from EntityController.php
- Loading branch information
Showing
4 changed files
with
117 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Entity; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class EntityHfdController extends Controller | ||
{ | ||
public function update(Entity $entity) | ||
{ | ||
$this->authorize('do-everything'); | ||
|
||
if ($entity->type->value !== 'idp') { | ||
return redirect() | ||
->back() | ||
->with('status', __('categories.hfd_controlled_for_idps_only')); | ||
} | ||
|
||
$entity = DB::transaction(function () use ($entity) { | ||
$entity->hfd = $entity->hfd ? false : true; | ||
$entity->update(); | ||
|
||
return $entity; | ||
}); | ||
|
||
$status = $entity->hfd ? 'hfd' : 'no_hfd'; | ||
$color = $entity->hfd ? 'red' : 'green'; | ||
|
||
//TODO change HfD status (not working) | ||
/* if ($entity->hfd) { | ||
GitAddToHfd::dispatch($entity, Auth::user()); | ||
Notification::send($entity->operators, new EntityAddedToHfd($entity)); | ||
Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityAddedToHfd($entity)); | ||
} else { | ||
GitDeleteFromHfd::dispatch($entity, Auth::user()); | ||
Mail::to(config('mail.ra.address'))->send(new NewIdentityProvider($entity)); | ||
Notification::send($entity->operators, new EntityDeletedFromHfd($entity)); | ||
Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityDeletedFromHfd($entity)); | ||
}*/ | ||
|
||
return redirect() | ||
->route('entities.show', $entity) | ||
->with('status', __("entities.$status")) | ||
->with('color', $color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters