1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Working on client side uploads

This commit is contained in:
David Bomba 2019-08-07 16:56:19 +10:00
parent c50fb68b21
commit 3e91a4f700
6 changed files with 40 additions and 4 deletions

View File

@ -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);

View File

@ -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,
)),
)
*/
}
/**

View File

@ -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);

View File

@ -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),
];
});

View File

@ -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();

View File

@ -76,9 +76,12 @@
function handleDocumentError(file, responseText) {
dropzone.removeFile(file);
// window.countUploadingDocuments--;
for (var error in responseText.errors) {
swal({title: '{{ctrans('texts.error')}}', text: responseText.errors[error]});
}
swal(responseText);
}
</script>
@endpush