2015-03-18 00:39:03 +01:00
|
|
|
<?php namespace App\Models;
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2015-03-27 06:02:19 +01:00
|
|
|
use Eloquent;
|
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
class InvoiceDesign extends Eloquent
|
|
|
|
{
|
|
|
|
public $timestamps = false;
|
2015-04-13 11:23:43 +02:00
|
|
|
|
|
|
|
public function scopeAvailableDesigns($query) {
|
|
|
|
$designs = $query->where('id', '<=', \Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
|
|
|
|
|
|
|
|
foreach($designs as $design) {
|
|
|
|
if($design->filename) {
|
2015-04-20 16:34:23 +02:00
|
|
|
$fileName = public_path(strtolower("js/templates/{$design->name}.js"));
|
2015-04-13 11:23:43 +02:00
|
|
|
if(file_exists($fileName)) {
|
|
|
|
$design->javascript = file_get_contents($fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $designs;
|
|
|
|
}
|
2015-03-16 22:45:25 +01:00
|
|
|
}
|