Issues (39)

Controllers/ChangeUserProfileInfoController.php (3 issues)

1
<?php
2
3
namespace MedianetDev\LaravelAuthApi\Http\Controllers;
4
5
use Illuminate\Support\Facades\Auth;
6
use MedianetDev\LaravelAuthApi\Http\Helpers\ApiResponse;
7
use MedianetDev\LaravelAuthApi\Http\Requests\ChangeUserProfileInfoRequest;
8
9
class ChangeUserProfileInfoController extends Controller
10
{
11
    /**
12
     * Create a new controller instance.
13
     *
14
     * @return void
15
     */
16
    public function __construct()
17
    {
18
        $this->middleware('auth:api');
19
    }
20
21
    public function update(ChangeUserProfileInfoRequest $request)
22
    {
23
        //TODO: encapsulate all the responses with ApiRequest
24
        $user = Auth::guard('apiauth')->user();
25
26
        $user->name = $request->name;
0 ignored issues
show
Accessing name on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
27
        $user->email = $request->email;
0 ignored issues
show
Accessing email on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
28
29
        if ($user->isDirty('email')) {
30
            // mark the email as not verified yet
31
            $user->email_verified_at = null;
0 ignored issues
show
Accessing email_verified_at on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
32
            // send a verification email
33
            $user->sendEmailVerificationNotification();
34
        }
35
36
        $user->save();
37
38
        return ApiResponse::send(['status' => 'Account updated successfully'], 1, 200, 'Account updated successfully');
39
    }
40
}
41