1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00
invoiceninja/app/Models/InvoiceDesign.php
2015-04-20 17:34:23 +03:00

24 lines
605 B
PHP

<?php namespace App\Models;
use Eloquent;
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) {
if($design->filename) {
$fileName = public_path(strtolower("js/templates/{$design->name}.js"));
if(file_exists($fileName)) {
$design->javascript = file_get_contents($fileName);
}
}
}
return $designs;
}
}