Fewo Mails / Booking Country Services
This commit is contained in:
parent
b9c26d06d0
commit
48a6eb2282
154 changed files with 7761 additions and 1643 deletions
106
app/Models/GeneralFile.php
Normal file
106
app/Models/GeneralFile.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class GeneralFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_id
|
||||
* @property string $identifier
|
||||
* @property string $filename
|
||||
* @property string $dir
|
||||
* @property string $original_name
|
||||
* @property string $ext
|
||||
* @property string $mine
|
||||
* @property int $size
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property TravelCountry $travel_country
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class GeneralFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'general_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id');
|
||||
}
|
||||
|
||||
public function getIconExt(){
|
||||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'general', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('general')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue