mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 20:27:33 -05:00 
			
		
		
		
	* Performance improvements moving from str_replace to strtr * Remove legacy docs * Clean up credit transformer * Working on invoice emails * Clean up for invoice designs * Tests for light and dark theme emails * Working on reminder scheduling * Reminder Job Class * Fixes for github actions * PHP CS * Test for reminders * Test for reminders
		
			
				
	
	
		
			112 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			112 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * Invoice Ninja (https://invoiceninja.com)
 | 
						|
 *
 | 
						|
 * @link https://github.com/invoiceninja/invoiceninja source repository
 | 
						|
 *
 | 
						|
 * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
 | 
						|
 *
 | 
						|
 * @license https://opensource.org/licenses/AAL
 | 
						|
 */
 | 
						|
 | 
						|
namespace App\Models;
 | 
						|
 | 
						|
use Illuminate\Database\Eloquent\Model;
 | 
						|
use Illuminate\Database\Eloquent\SoftDeletes;
 | 
						|
use Illuminate\Support\Facades\Storage;
 | 
						|
 | 
						|
class Document extends BaseModel
 | 
						|
{
 | 
						|
    use SoftDeletes;
 | 
						|
    
 | 
						|
    const DOCUMENT_PREVIEW_SIZE = 300; // pixels
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var array
 | 
						|
     */
 | 
						|
    protected $fillable = [
 | 
						|
        'is_default',
 | 
						|
    ];
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var array
 | 
						|
     */
 | 
						|
    public static $types = [
 | 
						|
        'png' => [
 | 
						|
            'mime' => 'image/png',
 | 
						|
        ],
 | 
						|
        'ai' => [
 | 
						|
            'mime' => 'application/postscript',
 | 
						|
        ],
 | 
						|
        'svg' => [
 | 
						|
            'mime' => 'image/svg+xml',
 | 
						|
        ],
 | 
						|
        'jpeg' => [
 | 
						|
            'mime' => 'image/jpeg',
 | 
						|
        ],
 | 
						|
        'tiff' => [
 | 
						|
            'mime' => 'image/tiff',
 | 
						|
        ],
 | 
						|
        'pdf' => [
 | 
						|
            'mime' => 'application/pdf',
 | 
						|
        ],
 | 
						|
        'gif' => [
 | 
						|
            'mime' => 'image/gif',
 | 
						|
        ],
 | 
						|
        'psd' => [
 | 
						|
            'mime' => 'image/vnd.adobe.photoshop',
 | 
						|
        ],
 | 
						|
        'txt' => [
 | 
						|
            'mime' => 'text/plain',
 | 
						|
        ],
 | 
						|
        'doc' => [
 | 
						|
            'mime' => 'application/msword',
 | 
						|
        ],
 | 
						|
        'xls' => [
 | 
						|
            'mime' => 'application/vnd.ms-excel',
 | 
						|
        ],
 | 
						|
        'ppt' => [
 | 
						|
            'mime' => 'application/vnd.ms-powerpoint',
 | 
						|
        ],
 | 
						|
        'xlsx' => [
 | 
						|
            'mime' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
 | 
						|
        ],
 | 
						|
        'docx' => [
 | 
						|
            'mime' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
 | 
						|
        ],
 | 
						|
        'pptx' => [
 | 
						|
            'mime' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
 | 
						|
        ],
 | 
						|
    ];
 | 
						|
 | 
						|
    /**
 | 
						|
     * @var array
 | 
						|
     */
 | 
						|
    public static $extraExtensions = [
 | 
						|
        'jpg' => 'jpeg',
 | 
						|
        'tif' => 'tiff',
 | 
						|
    ];
 | 
						|
 | 
						|
 | 
						|
    public function documentable()
 | 
						|
    {
 | 
						|
        return $this->morphTo();
 | 
						|
    }
 | 
						|
 | 
						|
    public function generateUrl($absolute = false)
 | 
						|
    {
 | 
						|
        $url = Storage::disk($this->disk)->url($this->path);
 | 
						|
 | 
						|
        if ($url && $absolute) {
 | 
						|
            return url($url);
 | 
						|
        }
 | 
						|
 | 
						|
        if ($url) {
 | 
						|
            return $url;
 | 
						|
        }
 | 
						|
 | 
						|
        return null;
 | 
						|
    }
 | 
						|
}
 |