Subversion-Projekte lars-tiefland.webanos.marine-sales.de

Revision

Revision 325 | Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
322 lars 1
<?php
2
 
3
    namespace App\Http\Requests;
4
 
5
    use App\Models\BackendUser;
6
    use Illuminate\Foundation\Http\FormRequest;
7
    use Illuminate\Validation\Rule;
8
 
9
    class UserUpdateRequest extends FormRequest
10
    {
11
        /**
12
         * Determine if the user is authorized to make this request.
13
         *
14
         * @return bool
15
         */
16
        public function authorize(): bool
17
        {
18
            if ( $_SESSION["admin"]["uid"] == $this->user()->id || $_SESSION["admin"]["user"]->admin == 1 || isset( $GLOBALS["user_rechte"]["admin"]["admin"] ) )
19
            {
20
                return true;
21
            }
22
            return false;
23
        }
24
 
25
        /**
26
         * Get the validation rules that apply to the request.
27
         *
28
         * @return array<string, mixed>
29
         */
30
        public function rules(): array
31
        {
32
            return [
33
                'email'             => 'bail|required|email|max:255', Rule::unique( BackendUser::class )->ignore( $this->user()->email ),
34
                'employee'          => 'integer|in:0,1',
35
                'rank'              => 'integer|min:0|max:500',
36
                'terminpflege'      => 'integer|in:0,1',
37
                'ignoreRemoteHosts' => 'integer|in:0,1',
38
                'description'       => 'sometimes',
39
                'phone'             => 'sometimes',
40
                'fax'               => 'sometimes',
41
                'save_session'      => 'integer|in:0,1',
42
                'app_user'          => 'integer|in:0,1',
43
            ];
44
        }
45
 
46
        protected function prepareForValidation(): void
47
        {
48
            $this->merge( [ "email" => $this->user . "@" . env( "shop" ) ] );
49
        }
50
    }