invoiceninja/app/Models/InvoiceDesign.php

24 lines
648 B
PHP
Raw Permalink Normal View History

2015-04-20 17:47:14 +03:00
<?php namespace app\Models;
2015-03-17 07:45:25 +10:00
2015-03-27 15:02:19 +10:00
use Eloquent;
2015-04-20 17:47:14 +03:00
use Auth;
2015-03-27 15:02:19 +10:00
2015-03-17 07:45:25 +10:00
class InvoiceDesign extends Eloquent
{
public $timestamps = false;
2015-04-20 17:47:14 +03:00
public function scopeAvailableDesigns($query)
{
$designs = $query->where('id', '<=', \Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
2015-04-21 14:42:31 +03:00
foreach ($designs as $design) {
$fileName = public_path(strtolower("js/templates/{$design->name}.js"));
if (Auth::user()->account->utf8_invoices && file_exists($fileName)) {
$design->javascript = file_get_contents($fileName);
2015-04-20 17:47:14 +03:00
}
2015-04-13 12:23:43 +03:00
}
2015-04-20 17:47:14 +03:00
return $designs;
2015-04-13 12:23:43 +03:00
}
2015-03-17 07:45:25 +10:00
}