Transfer Show page file updates..
This commit is contained in:
@ -3,16 +3,20 @@
|
||||
namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Common\Media as MediaModel;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\Media;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Transfer extends Model
|
||||
{
|
||||
use BelongsToThrough, Currencies, HasFactory;
|
||||
use BelongsToThrough, Currencies, HasFactory, Media;
|
||||
|
||||
protected $table = 'transfers';
|
||||
|
||||
protected $appends = ['attachment'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
@ -59,6 +63,36 @@ class Transfer extends Model
|
||||
)->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value = null)
|
||||
{
|
||||
if (!empty($value) && !$this->hasMedia('attachment')) {
|
||||
return $value;
|
||||
} elseif (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->all();
|
||||
}
|
||||
|
||||
public function delete_attachment()
|
||||
{
|
||||
if ($attachments = $this->attachment) {
|
||||
foreach ($attachments as $file) {
|
||||
MediaModel::where('id', $file->id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTemplatePathAttribute($value = null)
|
||||
{
|
||||
return $value ?: 'banking.transfers.print_' . setting('transfer.template');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
|
Reference in New Issue
Block a user