forked from Silvanite/novatoolpermissions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Silvanite#36 from SGS-Optimisation/feature/17-op-f…
…lagged-rules Feature/17 op flagged rules
- Loading branch information
Showing
7 changed files
with
171 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Rule; | ||
use Carbon\Carbon; | ||
use Illuminate\Http\Request; | ||
|
||
class RuleFlaggingController extends Controller | ||
{ | ||
|
||
public function on(Request $request, Rule $rule) | ||
{ | ||
$rule->flagged = true; | ||
|
||
$metadata = $rule->metadata ?? []; | ||
|
||
if(!isset($metadata['flag_reason'])) { | ||
$metadata['flag_reason'] = []; | ||
} | ||
|
||
$metadata['flag_reason'][] = [ | ||
'user' => $request->user()->name, | ||
'reason' => $request->reason, | ||
'date' => Carbon::now()->format('Y-m-d H:i:s'), | ||
]; | ||
|
||
$rule->metadata = $metadata; | ||
$rule->timestamps = false; | ||
|
||
$rule->save(); | ||
|
||
\Log::debug('flagging rule ' . $rule->id); | ||
logger('reason: ' . $request->reason); | ||
|
||
return back(); | ||
} | ||
} |
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
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
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