FEATURE #1451: add logging to all actions in widget management
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Events\AssignWidget;
|
||||
use App\Events\RemoveWidgetFromArea;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests;
|
||||
use App\Models\Widget;
|
||||
use App\Models\WidgetArea;
|
||||
use App\Models\WidgetInWidgetArea;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class AssociateWidget extends Controller
|
||||
{
|
||||
@@ -26,6 +29,10 @@ class AssociateWidget extends Controller
|
||||
|
||||
public function makeAssociation($widgetId, $widgetAreaId)
|
||||
{
|
||||
// check if given values are valid
|
||||
$widget = Widget::findOrFail($widgetId);
|
||||
$widgetArea = WidgetArea::findOrFail($widgetAreaId);
|
||||
|
||||
try {
|
||||
WidgetInWidgetArea::create(['widget_id' => $widgetId, 'widget_area_id' => $widgetAreaId]);
|
||||
} catch (QueryException $e) {
|
||||
@@ -34,6 +41,8 @@ class AssociateWidget extends Controller
|
||||
->with('error', trans('admin/widgets.associationExists'));
|
||||
}
|
||||
|
||||
Event::fire(new AssignWidget($widget, $widgetArea));
|
||||
|
||||
return redirect()
|
||||
->route('widgets.associate', ['widgetArea' => $widgetAreaId])
|
||||
->with('success', trans('admin/widgets.successfullyAssociated'));
|
||||
@@ -41,6 +50,10 @@ class AssociateWidget extends Controller
|
||||
|
||||
public function deleteAssociation($widgetId, $widgetAreaId)
|
||||
{
|
||||
// check if given values are valid
|
||||
$widget = Widget::findOrFail($widgetId);
|
||||
$widgetArea = WidgetArea::findOrFail($widgetAreaId);
|
||||
|
||||
$widgetInArea = WidgetInWidgetArea::where('widget_id', $widgetId)
|
||||
->where('widget_area_id', $widgetAreaId);
|
||||
|
||||
@@ -52,6 +65,8 @@ class AssociateWidget extends Controller
|
||||
|
||||
$widgetInArea->delete();
|
||||
|
||||
Event::fire(new RemoveWidgetFromArea($widget, $widgetArea));
|
||||
|
||||
return redirect()
|
||||
->route('widgets.associate', ['widgetArea' => $widgetAreaId])
|
||||
->with('success', trans('admin/widgets.successfullyDeassociated'));
|
||||
|
||||
Reference in New Issue
Block a user