mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Enable is_public for document uploads
This commit is contained in:
parent
4eb376e830
commit
0a493c275e
@ -18,7 +18,7 @@ class UploadController extends Controller
|
||||
*/
|
||||
public function __invoke(StoreUploadRequest $request)
|
||||
{
|
||||
$this->saveDocuments($request->getFile(), auth()->user()->client);
|
||||
$this->saveDocuments($request->getFile(), auth()->user()->client, true);
|
||||
|
||||
return response([], 200);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class DownloadsTable extends Component
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = auth()->user()->client->documents();
|
||||
$query = auth('contact')->user()->client->documents();
|
||||
|
||||
if (in_array('resources', $this->status) && !in_array('client', $this->status)) {
|
||||
$query = $query->where('documentable_type', '!=', 'App\Models\Client');
|
||||
@ -39,6 +39,7 @@ class DownloadsTable extends Component
|
||||
}
|
||||
|
||||
$query = $query
|
||||
->where('is_public', true)
|
||||
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
|
||||
->paginate($this->per_page);
|
||||
|
||||
|
@ -44,10 +44,11 @@ class UploadFile implements ShouldQueue
|
||||
protected $user;
|
||||
protected $company;
|
||||
protected $type;
|
||||
protected $is_public;
|
||||
|
||||
public $entity;
|
||||
|
||||
public function __construct($file, $type, $user, $company, $entity, $disk = null)
|
||||
public function __construct($file, $type, $user, $company, $entity, $disk = null, $is_public = false)
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->type = $type;
|
||||
@ -55,6 +56,7 @@ class UploadFile implements ShouldQueue
|
||||
$this->company = $company;
|
||||
$this->entity = $entity;
|
||||
$this->disk = $disk ?? config('filesystems.default');
|
||||
$this->is_public = $is_public;
|
||||
|
||||
//MultiDB::setDB($this->company->db);
|
||||
}
|
||||
@ -96,6 +98,7 @@ class UploadFile implements ShouldQueue
|
||||
$document->size = $this->file->getSize();
|
||||
$document->width = isset($width) ? $width : null;
|
||||
$document->height = isset($height) ? $height : null;
|
||||
$document->is_public = $this->is_public;
|
||||
|
||||
// $preview_path = $this->encodePrimaryKey($this->company->id);
|
||||
// $document->preview = $this->generatePreview($preview_path);
|
||||
|
@ -17,7 +17,7 @@ use App\Models\Company;
|
||||
|
||||
trait SavesDocuments
|
||||
{
|
||||
public function saveDocuments($document_array, $entity)
|
||||
public function saveDocuments($document_array, $entity, $is_public = false)
|
||||
{
|
||||
if ($entity instanceof Company) {
|
||||
$account = $entity->account;
|
||||
@ -37,7 +37,9 @@ trait SavesDocuments
|
||||
UploadFile::DOCUMENT,
|
||||
$entity->user,
|
||||
$entity->company,
|
||||
$entity
|
||||
$entity,
|
||||
null,
|
||||
$is_public
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIsPublicToDocumentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->boolean('is_public')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->dropColumn('is_public');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user