diff --git a/app/Factory/ClientFactory.php b/app/Factory/ClientFactory.php index de681690ef..eb1bb96150 100644 --- a/app/Factory/ClientFactory.php +++ b/app/Factory/ClientFactory.php @@ -28,6 +28,8 @@ class ClientFactory $client->paid_to_date = 0; $client->country_id = 4; $client->is_deleted = 0; + $client->client_hash = str_random(40); + $client->settings = new ClientSettings(ClientSettings::defaults()); $client_contact = ClientContactFactory::create($company_id, $user_id); diff --git a/app/Http/Controllers/ClientPortal/DocumentController.php b/app/Http/Controllers/ClientPortal/DocumentController.php index 041fcbcb7a..1d6866d1e7 100644 --- a/app/Http/Controllers/ClientPortal/DocumentController.php +++ b/app/Http/Controllers/ClientPortal/DocumentController.php @@ -15,6 +15,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\ClientPortal\StoreDocumentRequest; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Storage; class DocumentController extends Controller { @@ -47,7 +48,34 @@ class DocumentController extends Controller */ public function store(StoreDocumentRequest $request) { + $contact = auth()->user(); + Log::error($request->all()); + + Storage::makeDirectory(public_path() . $contact->client->client_hash, 0755); + + $path = Storage::putFile($contact->client->client_hash, $request->file('file')); + + $url = Storage::url($path); + + Log::error($path); + Log::error($url); + + /* + [2019-08-07 05:50:23] local.ERROR: array ( + '_token' => '7KoEVRjB2Fq8XBVFRUFbhQFjKm4rY9h0AGSlpdj3', + 'is_avatar' => '1', + 'q' => '/client/document', + 'file' => + Illuminate\Http\UploadedFile::__set_state(array( + 'test' => false, + 'originalName' => 'family.jpg', + 'mimeType' => 'image/jpeg', + 'error' => 0, + 'hashName' => NULL, + )), + ) + */ } /** diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 7e62b34524..78861d5b8f 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -47,7 +47,7 @@ class QueryLogging $count = count($queries); $timeEnd = microtime(true); $time = $timeEnd - $timeStart; - Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); + //Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); if($count > 16) Log::info($queries); diff --git a/database/factories/ClientFactory.php b/database/factories/ClientFactory.php index 396e4eb5de..c09628f546 100644 --- a/database/factories/ClientFactory.php +++ b/database/factories/ClientFactory.php @@ -29,5 +29,6 @@ $factory->define(App\Models\Client::class, function (Faker $faker) { 'shipping_postal_code' => $faker->postcode, 'shipping_country_id' => 4, 'settings' => new ClientSettings(ClientSettings::defaults()), + 'client_hash' => str_random(40), ]; }); diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index ebf9850625..3bd4a45308 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -262,6 +262,8 @@ class CreateUsersTable extends Migration $table->string('name')->nullable(); $table->string('website')->nullable(); $table->text('private_notes')->nullable(); + $table->text('client_hash')->nullable(); + $table->decimal('balance', 13, 2)->nullable(); $table->decimal('paid_to_date', 13, 2)->nullable(); $table->timestamp('last_login')->nullable(); diff --git a/resources/views/generic/dropzone.blade.php b/resources/views/generic/dropzone.blade.php index 2bf1af3ebf..f678294385 100644 --- a/resources/views/generic/dropzone.blade.php +++ b/resources/views/generic/dropzone.blade.php @@ -76,9 +76,12 @@ function handleDocumentError(file, responseText) { dropzone.removeFile(file); // window.countUploadingDocuments--; - - - swal(responseText); + for (var error in responseText.errors) { + + swal({title: '{{ctrans('texts.error')}}', text: responseText.errors[error]}); + + } + } @endpush \ No newline at end of file