Skip to content

Commit

Permalink
Add edit page attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jan 2, 2018
1 parent ddd18c7 commit dd68640
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Filters/Banking/Transfers.php
Expand Up @@ -23,4 +23,4 @@ public function toAccount($account_id)
{
return $this->related('revenue', 'revenues.account_id', '=', $account_id);
}
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Expenses/Bills.php
Expand Up @@ -134,7 +134,7 @@ public function store(Request $request)
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'revenues');

$invoice->attachMedia($media, 'attachment');
$bill->attachMedia($media, 'attachment');
}

$taxes = [];
Expand Down Expand Up @@ -458,7 +458,7 @@ public function update(Bill $bill, Request $request)
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'bills');

$bill->syncMedia($media, 'attachment');
$bill->attachMedia($media, 'attachment');
}

// Added bill total total
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Expenses/Payments.php
Expand Up @@ -182,7 +182,7 @@ public function update(Payment $payment, Request $request)
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'payments');

$payment->syncMedia($media, 'attachment');
$payment->attachMedia($media, 'attachment');
}

$message = trans('messages.success.updated', ['type' => trans_choice('general.payments', 1)]);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Incomes/Revenues.php
Expand Up @@ -85,7 +85,7 @@ public function store(Request $request)
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'revenues');

$revenue->syncMedia($media, 'attachment');
$revenue->attachMedia($media, 'attachment');
}

$message = trans('messages.success.added', ['type' => trans_choice('general.revenues', 1)]);
Expand Down Expand Up @@ -184,7 +184,7 @@ public function update(Revenue $revenue, Request $request)
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'revenues');

$revenue->syncMedia($media, 'attachment');
$revenue->attachMedia($media, 'attachment');
}

$message = trans('messages.success.updated', ['type' => trans_choice('general.revenues', 1)]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Items/Items.php
Expand Up @@ -144,7 +144,7 @@ public function update(Item $item, Request $request)
if ($request->file('picture')) {
$media = $this->getMedia($request->file('picture'), 'items');

$item->syncMedia($media, 'picture');
$item->attachMedia($media, 'picture');
}

$message = trans('messages.success.updated', ['type' => trans_choice('general.items', 1)]);
Expand Down
18 changes: 18 additions & 0 deletions resources/views/incomes/invoices/edit.blade.php
Expand Up @@ -208,6 +208,24 @@ function addItem() {
@endif
});
@if($invoice->attachment)
attachment_html = '<span class="attachment">';
attachment_html += ' <a href="{{ url('uploads/' . $invoice->attachment->id . '/download') }}">';
attachment_html += ' <span id="download-attachment" class="text-primary">';
attachment_html += ' <i class="fa fa-file-{{ $invoice->attachment->aggregate_type }}-o"></i> {{ $invoice->attachment->basename }}';
attachment_html += ' </span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $invoice->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $invoice->attachment->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' {{ Form::hidden('id', $invoice->id) }}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::close() !!}';
attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html);
@endif
var autocomplete_path = "{{ url('items/items/autocomplete') }}";
$(document).on('click', '.form-control.typeahead', function() {
Expand Down

0 comments on commit dd68640

Please sign in to comment.