2019-08-02 02:31:48 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2019-08-12 14:45:13 +02:00
|
|
|
use App\Http\Requests\ClientPortal\UpdateContactRequest;
|
2019-08-14 02:15:21 +02:00
|
|
|
use App\Http\Requests\ClientPortal\UpdateClientRequest;
|
2019-08-13 01:56:46 +02:00
|
|
|
use App\Jobs\Util\UploadAvatar;
|
2019-08-02 02:31:48 +02:00
|
|
|
use App\Models\ClientContact;
|
|
|
|
use Illuminate\Http\Request;
|
2019-08-13 01:56:46 +02:00
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
2019-08-02 02:31:48 +02:00
|
|
|
|
|
|
|
class ProfileController extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function edit(ClientContact $client_contact)
|
|
|
|
{
|
2019-08-08 02:22:54 +02:00
|
|
|
/* Dropzone configuration */
|
2019-08-07 02:44:38 +02:00
|
|
|
$data = [
|
|
|
|
'params' => [
|
|
|
|
'is_avatar' => TRUE,
|
|
|
|
],
|
|
|
|
'url' => '/client/document',
|
|
|
|
'multi_upload' => FALSE,
|
|
|
|
];
|
|
|
|
|
|
|
|
return view('portal.default.profile.index', $data);
|
2019-08-02 02:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2019-08-12 14:45:13 +02:00
|
|
|
public function update(UpdateContactRequest $request, ClientContact $client_contact)
|
2019-08-02 02:31:48 +02:00
|
|
|
{
|
2019-08-12 14:45:13 +02:00
|
|
|
|
2019-08-13 01:56:46 +02:00
|
|
|
$client_contact->fill($request->all());
|
|
|
|
|
|
|
|
//update password if needed
|
|
|
|
if($request->input('password'))
|
|
|
|
$client_contact->password = Hash::make($request->input('password'));
|
|
|
|
|
|
|
|
$client_contact->save();
|
|
|
|
|
|
|
|
// auth()->user()->fresh();
|
|
|
|
|
|
|
|
return back();
|
2019-08-02 02:31:48 +02:00
|
|
|
}
|
|
|
|
|
2019-08-14 02:15:21 +02:00
|
|
|
public function updateClient(UpdateClientRequest $request, ClientContact $client_contact)
|
2019-08-13 23:16:31 +02:00
|
|
|
{
|
2019-08-14 02:15:21 +02:00
|
|
|
|
|
|
|
$client = $client_contact->client;
|
|
|
|
|
2019-08-26 11:28:21 +02:00
|
|
|
//update avatar if needed
|
|
|
|
if($request->file('logo'))
|
|
|
|
{
|
|
|
|
$path = UploadAvatar::dispatchNow($request->file('logo'), auth()->user()->client->client_hash);
|
|
|
|
|
|
|
|
if($path)
|
|
|
|
$client->logo = $path;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-14 02:15:21 +02:00
|
|
|
$client->fill($request->all());
|
|
|
|
$client->save();
|
|
|
|
|
2019-08-13 23:16:31 +02:00
|
|
|
return back();
|
|
|
|
}
|
2019-08-02 02:31:48 +02:00
|
|
|
}
|