Prachee
3 months ago
323
2
Laravel

ParseError syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ']' http://localhost/Laravel/public/account

Posted 3 months ago by Prachee

Web.php file Route::get('/account',[ 'uses' => '[email protected]', 'as' => 'account' ]);

Route::post('/updateaccount'[
	'uses' => '[email protected]',
	'as' => 'account.save'
]);

UserController.php FILE

public function getAccount() { return view('account', ['user' => Auth::user()]); } public function postSaveAccount(Request $request) { $this->validate($request, [ 'first_name' => 'required|max:120' ]);

    $user = Auth::user();
    $old_name = $user->first_name;
    $user->first_name = $request['first_name'];
    $user->update();
    $file = $request->file('image');
    $filename = $request['first_name'] . '-' . $user->id . '.jpg';
    $old_filename = $old_name . '-' . $user->id . '.jpg';
    $update = false;
    if (Storage::disk('local')->has($old_filename)) {
        $old_file = Storage::disk('local')->get($old_filename);
        Storage::disk('local')->put($filename, $old_file);
        $update = true;
    }
    if ($file) {
        Storage::disk('local')->put($filename, File::get($file));
    }
    if ($update && $old_filename !== $filename) {
        Storage::delete($old_filename);
    }
    return redirect()->route('account');
}

Please sign in or create an account to participate in this conversation.