Your Shop creates, verify user

This commit is contained in:
Kevin Adametz 2019-01-04 18:46:48 +01:00
parent c129a44383
commit ccc2af4bf7
76 changed files with 3728 additions and 1477 deletions

View file

@ -1,134 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\Account
*
* @property int $id
* @property int $user_id
* @property int $company
* @property string|null $company_name
* @property string|null $company_street
* @property string|null $company_postal_code
* @property string|null $company_city
* @property int|null $company_pre_phone_id
* @property string|null $company_phone
* @property string|null $company_homepage
* @property int|null $company_country_id
* @property string|null $salutation
* @property string|null $title
* @property string|null $first_name
* @property string|null $last_name
* @property string|null $street
* @property string|null $postal_code
* @property string|null $city
* @property int|null $country_id
* @property int|null $pre_phone_id
* @property string|null $phone
* @property int|null $pre_mobil_id
* @property string|null $mobil
* @property string|null $birthday
* @property string|null $website
* @property string|null $facebook
* @property string|null $facebook_fanpage
* @property string|null $instagram
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\Country|null $company_country
* @property-read \App\Models\Country|null $company_pre_phone
* @property-read \App\Models\Country|null $country
* @property-read \App\Models\Country|null $pre_mobil
* @property-read \App\Models\Country|null $pre_phone
* @property-read \App\User $user
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account onlyTrashed()
* @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereBirthday($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyHomepage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPostalCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPrePhoneId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFacebook($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFacebookFanpage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFirstName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereInstagram($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereMobil($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePostalCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePreMobilId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePrePhoneId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereWebsite($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account withoutTrashed()
* @mixin \Eloquent
*/
class Account extends Model
{
protected $table = 'accounts';
use SoftDeletes;
protected $dates = ['deleted_at'];
public function user()
{
return $this->belongsTo('App\User');
}
public function company_country()
{
return $this->belongsTo('App\Models\Country', 'company_country_id');
}
public function country()
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
public function company_pre_phone()
{
return $this->belongsTo('App\Models\Country', 'company_pre_phone_id');
}
public function pre_phone()
{
return $this->belongsTo('App\Models\Country', 'pre_phone_id');
}
public function pre_mobil()
{
return $this->belongsTo('App\Models\Country', 'pre_mobil_id');
}
public function getCompanyAttribute(){
if(empty($this->attributes['company']) && @$this->attributes['company'] !== 0){
return 1;
}
return $this->attributes['company'];
}
}

View file

@ -28,6 +28,9 @@ use Illuminate\Database\Eloquent\Model;
* @mixin \Eloquent
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute query()
*/
class Attribute extends Model
{

View file

@ -31,6 +31,9 @@ use Cviebrock\EloquentSluggable\Sluggable;
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $product_categories
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category query()
*/
class Category extends Model
{

View file

@ -27,6 +27,9 @@ use PHPUnit\Framework\Constraint\Count;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereRu($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country query()
*/
class Country extends Model
{

View file

@ -74,6 +74,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product query()
*/
class Product extends Model
{
@ -134,34 +137,6 @@ class Product extends Model
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id');
}
/*
public function isImageAfter(){
if(empty($this->attributes['filename_after']) || @$this->attributes['filename_after'] == null || @$this->attributes['filename_after'] == ""){
return false;
}
if(!\Storage::disk('public')->has('images/'.$this->id.'/'.$this->filename_after)){
return false;
}
return true;
}
public function getImage($file){
if($file == "before" && $this->isImageBefore()){
$link = 'images/'.$this->id.'/'.$this->filename_before;
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
}
if($file == "after" && $this->isImageAfter()){
$link = 'images/'.$this->id.'/'.$this->filename_after;
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
}
return false;
}
*/
public function _format_number($value){

View file

@ -20,6 +20,9 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereUpdatedAt($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute query()
*/
class ProductAttribute extends Model
{

View file

@ -20,6 +20,9 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereUpdatedAt($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory query()
*/
class ProductCategory extends Model
{

View file

@ -33,6 +33,9 @@ use Illuminate\Database\Eloquent\Model;
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
*/
class ProductImage extends Model
{

View file

@ -0,0 +1,96 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Carbon\Carbon;
/**
* App\Models\UserAccount
*
* @property-read \App\Models\Country $company_country
* @property-read \App\Models\Country $company_pre_phone
* @property-read \App\Models\Country $country
* @property mixed $birthday
* @property-read mixed $company
* @property-read \App\Models\Country $pre_mobil
* @property-read \App\Models\Country $pre_phone
* @property-read \App\User $user
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount newQuery()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount query()
* @method static bool|null restore()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withoutTrashed()
* @mixin \Eloquent
*/
class UserAccount extends Model
{
protected $table = 'user_accounts';
use SoftDeletes;
protected $dates = ['deleted_at'];
public function user()
{
return $this->hasOne('App\User', 'account_id');
}
public function company_country()
{
return $this->belongsTo('App\Models\Country', 'company_country_id');
}
public function country()
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
public function company_pre_phone()
{
return $this->belongsTo('App\Models\Country', 'company_pre_phone_id');
}
public function pre_phone()
{
return $this->belongsTo('App\Models\Country', 'pre_phone_id');
}
public function pre_mobil()
{
return $this->belongsTo('App\Models\Country', 'pre_mobil_id');
}
public function getCompanyAttribute(){
if(empty($this->attributes['company']) && @$this->attributes['company'] !== 0){
return 1;
}
return $this->attributes['company'];
}
public function getBirthdayAttribute($value)
{
if(!$value){
return "";
}
return Carbon::parse($value)->format(\Util::formatDateDB());
}
public function setBirthdayAttribute( $value ) {
$this->attributes['birthday'] = (new Carbon($value))->format('Y-m-d');
}
public function getDataProtectionFormat(){
if(!$this->attributes['data_protection']){ return ""; }
return Carbon::parse($this->attributes['data_protection'])->format(\Util::formatDateTimeDB());
}
}

98
app/Models/UserShop.php Normal file
View file

@ -0,0 +1,98 @@
<?php
namespace App\Models;
use App\Http\Controllers\Api\KasController;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class UserShop extends Model
{
protected $table = 'user_shops';
protected $is_online = NULL;
protected $casts = [
'trans_title' => 'array',
'trans_copy' => 'array',
'trans_info' => 'array',
'featured' => 'array',
];
protected $fillable = [
'user_id', 'name', 'active', 'active_date',
];
use SoftDeletes;
protected $dates = ['deleted_at'];
use Sluggable;
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
public function getActiveDateFormat(){
if(!$this->attributes['active_date']){ return ""; }
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
}
public function getSubdomain()
{
return config('app.protocol').$this->attributes['slug'].".".config('app.domain');
}
public function getSubdomainStatus()
{
if($this->is_online != NULL){
return $this->is_online;
}
$kas = new KasController();
$domain = 'mivita.care';
$pra = array(
'subdomain_name' => $this->attributes['slug'].".".$domain,
'domain_name' => $this->attributes['slug'].".".$domain,
);
//check if exisist
$subdomain = $kas->action('get_subdomains', $pra);
if(!empty($subdomain[0]['is_active']) && $subdomain[0]['is_active'] == 'Y'){
$this->is_online = true;
return true;
}
$this->is_online = false;
return false;
}
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;
}
}

View file

@ -9,10 +9,13 @@ use Illuminate\Database\Eloquent\Model;
*
* @property-read \App\User $user
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail query()
*/
class UserUpdateEmail extends Model
{
protected $table = 'users_update_email';
protected $table = 'user_update_emails';
protected $fillable = [
'user_id', 'email', 'token',