2019-08-02 02:31:48 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-08-02 02:31:48 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-08-02 02:31:48 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-08-02 02:31:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2019-08-14 02:15:21 +02:00
|
|
|
use App\Http\Requests\ClientPortal\UpdateClientRequest;
|
2020-09-06 11:38:10 +02:00
|
|
|
use App\Http\Requests\ClientPortal\UpdateContactRequest;
|
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;
|
2020-10-28 11:10:49 +01:00
|
|
|
use Illuminate\Contracts\View\Factory;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
use Illuminate\View\View;
|
2019-08-02 02:31:48 +02:00
|
|
|
|
|
|
|
class ProfileController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
2020-03-23 18:10:42 +01:00
|
|
|
* @param ClientContact $client_contact
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Factory|View
|
2019-08-02 02:31:48 +02:00
|
|
|
*/
|
|
|
|
public function edit(ClientContact $client_contact)
|
|
|
|
{
|
2020-03-23 18:10:42 +01:00
|
|
|
return $this->render('profile.index');
|
2019-08-02 02:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
2020-03-23 18:10:42 +01:00
|
|
|
* @param UpdateContactRequest $request
|
|
|
|
* @param ClientContact $client_contact
|
2024-06-16 00:30:25 +02:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2019-08-02 02:31:48 +02:00
|
|
|
*/
|
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-13 01:56:46 +02:00
|
|
|
$client_contact->fill($request->all());
|
|
|
|
|
2020-03-23 18:10:42 +01:00
|
|
|
if ($request->has('password')) {
|
|
|
|
$client_contact->password = encrypt($request->password);
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-08-13 01:56:46 +02:00
|
|
|
|
|
|
|
$client_contact->save();
|
|
|
|
|
2020-03-23 18:10:42 +01:00
|
|
|
return back()->withSuccess(
|
|
|
|
ctrans('texts.profile_updated_successfully')
|
|
|
|
);
|
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
|
2019-12-30 22:59:12 +01:00
|
|
|
if ($request->file('logo')) {
|
2023-08-04 08:40:44 +02:00
|
|
|
$path = (new UploadAvatar($request->file('logo'), $client->client_hash))->handle();
|
2019-08-26 11:28:21 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
if ($path) {
|
2019-08-26 11:28:21 +02:00
|
|
|
$client->logo = $path;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-08-26 11:28:21 +02:00
|
|
|
}
|
|
|
|
|
2019-08-14 02:15:21 +02:00
|
|
|
$client->fill($request->all());
|
|
|
|
$client->save();
|
|
|
|
|
2020-03-23 18:10:42 +01:00
|
|
|
return back()->withSuccess(
|
|
|
|
ctrans('texts.profile_updated_successfully')
|
|
|
|
);
|
2019-08-13 23:16:31 +02:00
|
|
|
}
|
2019-08-02 02:31:48 +02:00
|
|
|
}
|