user shop sites
This commit is contained in:
parent
22a2b4710a
commit
dc857e88d5
37 changed files with 2044 additions and 869 deletions
|
|
@ -57,7 +57,6 @@ class ProductImage extends Model
|
|||
];
|
||||
}
|
||||
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Product', 'product_id');
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@ class UserShop extends Model
|
|||
protected $is_online = NULL;
|
||||
|
||||
protected $casts = [
|
||||
'trans_title' => 'array',
|
||||
'trans_copy' => 'array',
|
||||
'trans_info' => 'array',
|
||||
'featured' => 'array',
|
||||
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
|
|
@ -42,6 +38,10 @@ class UserShop extends Model
|
|||
return $this->belongsTo('App\User', 'user_id');
|
||||
}
|
||||
|
||||
public function on_sites(){
|
||||
return $this->hasMany('App\Models\UserShopOnSite', 'user_shop_id', 'id');
|
||||
}
|
||||
|
||||
public function getActiveDateFormat(){
|
||||
if(!$this->attributes['active_date']){ return ""; }
|
||||
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
|
||||
|
|
@ -52,7 +52,6 @@ class UserShop extends Model
|
|||
return Carbon::parse($this->attributes['active_date'])->format("d.m.Y");
|
||||
}
|
||||
|
||||
|
||||
public function getSubdomain()
|
||||
{
|
||||
return config('app.protocol').$this->attributes['slug'].".".config('app.domain');
|
||||
|
|
@ -82,6 +81,28 @@ class UserShop extends Model
|
|||
}
|
||||
|
||||
|
||||
public function getSubdomainAvailable ()
|
||||
{
|
||||
$rCurlHandle = curl_init ( $this->attributes['slug'].".mivita.care" );
|
||||
|
||||
curl_setopt ( $rCurlHandle, CURLOPT_CONNECTTIMEOUT, 10 );
|
||||
curl_setopt ( $rCurlHandle, CURLOPT_HEADER, TRUE );
|
||||
curl_setopt ( $rCurlHandle, CURLOPT_NOBODY, TRUE );
|
||||
curl_setopt ( $rCurlHandle, CURLOPT_RETURNTRANSFER, TRUE );
|
||||
|
||||
$strResponse = curl_exec ( $rCurlHandle );
|
||||
|
||||
curl_close ( $rCurlHandle );
|
||||
|
||||
if ( !$strResponse )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function isImage(){
|
||||
if(empty($this->attributes['filename']) || @$this->attributes['filename'] == null || @$this->attributes['filename'] == ""){
|
||||
|
|
|
|||
65
app/Models/UserShopOnSite.php
Normal file
65
app/Models/UserShopOnSite.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserShopOnSite extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
protected $table = 'user_shop_on_sites';
|
||||
|
||||
protected $fillable = [
|
||||
'user_shop_id', 'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'original_name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isImage(){
|
||||
if(empty($this->attributes['filename']) || @$this->attributes['filename'] == null || @$this->attributes['filename'] == ""){
|
||||
return false;
|
||||
}
|
||||
if(!\Storage::disk('public')->has('images/shop/'.$this->filename)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getImage(){
|
||||
if($this->isImage()){
|
||||
$link = 'images/shop/'.$this->filename;
|
||||
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue