1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/app/Models/InvoiceDesign.php
2015-04-21 14:42:31 +03:00

24 lines
648 B
PHP

<?php namespace app\Models;
use Eloquent;
use Auth;
class InvoiceDesign extends Eloquent
{
public $timestamps = false;
public function scopeAvailableDesigns($query)
{
$designs = $query->where('id', '<=', \Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
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);
}
}
return $designs;
}
}