Last change
on this file since f457265 was d25ba66, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago |
ADD post confirmation with multiple phases, notification after succesfully password creation
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d25ba66] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Requests\Dashboard;
|
---|
| 4 |
|
---|
| 5 | use App\Models\Phase;
|
---|
| 6 | use Illuminate\Foundation\Http\FormRequest;
|
---|
| 7 |
|
---|
| 8 | class PostSecurityRequest extends FormRequest
|
---|
| 9 | {
|
---|
| 10 | /**
|
---|
| 11 | * Determine if the user is authorized to make this request.
|
---|
| 12 | *
|
---|
| 13 | * @return bool
|
---|
| 14 | */
|
---|
| 15 | public function authorize()
|
---|
| 16 | {
|
---|
| 17 | if ($this->has("post_security_id") && !is_null($this->request->get("post_security_id"))) {
|
---|
| 18 | return auth()->user()->hasPermission("edit_post_securities");
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | return auth()->user()->hasPermission("create_post_securities");
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * Get the validation rules that apply to the request.
|
---|
| 26 | *
|
---|
| 27 | * @return array
|
---|
| 28 | */
|
---|
| 29 | public function rules()
|
---|
| 30 | {
|
---|
| 31 | return [
|
---|
| 32 | "role_id_to_be_reviewed" => "required|exists:roles,id",
|
---|
| 33 | "phase_ids" => [
|
---|
| 34 | "required",
|
---|
| 35 | function($attribute, $value, $fail) {
|
---|
| 36 | $phases = explode(",", $value);
|
---|
| 37 | foreach ($phases as $phase) {
|
---|
| 38 | if(is_null(Phase::find($phase))) {
|
---|
| 39 | $fail("Error occurred. Please try again!");
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 | ],
|
---|
| 44 | ];
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public function attributes()
|
---|
| 48 | {
|
---|
| 49 | return [
|
---|
| 50 | "phase_ids" => "phases"
|
---|
| 51 | ];
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.