some cleanup

pull/1/head
farid saravi 5 years ago
parent ca0a7f70aa
commit 9388bf4eaa

@ -1,26 +0,0 @@
<?php
// this is comment in address
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Address extends Model
{
use SoftDeletes;
protected $fillable = ['city_id', 'title', 'postal_code', 'phones', 'addressable_id', 'addressable_type', 'district_id'];
protected $dates = ['deleted_at'];
public function addressable()
{
return $this->morphTo();
}
public function city ()
{
return $this->belongsTo('App\City');
}
}

@ -1,34 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Attribute extends Model
{
protected $fillable = ['name_front', 'name_back','type','has_tag', 'for_section', 'category_id'];
protected $hidden = ['pivot'];
public function values()
{
return $this->hasMany('App\AttributeValue');
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function businesses()
{
return $this->belongsToMany('App\Business');
}
public function products()
{
return $this->belongsToMany('App\Product');
}
}

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AttributeValue extends Model
{
protected $fillable = ['name', 'slug', 'details', 'attribute_id'];
public $timestamps = false;
public function attribute()
{
return $this->belongsTo('App\Attribute');
}
}

@ -1,23 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Auction extends Model
{
protected $fillable = ['min_price', 'step', 'expire_date'];
public function orders ()
{
return $this->hasMany('App\Order');
}
public function business_item_variation ()
{
return $this->belongsTo('App\BusinessItemVariation');
}
}

@ -1,27 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BatchShoppingCart extends Model
{
protected $fillable = ['slug', 'details'];
public $timestamps = false;
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
public function shopping_carts()
{
return $this->hasMany('App\ShoppingCart');
}
}

@ -1,74 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class Blog extends Model
{
use GetDateAttributesTrait;
public $fillable = ['title', 'description', 'summary', 'blog_category_id', 'user_id'];
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function category()
{
return $this->belongsTo('App\BlogCategory', 'blog_category_id');
}
public function categories()
{
return $this->belongsToMany('App\BlogCategory', 'blog_blog_category');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function likes()
{
return $this->morphMany('App\Like', 'likeable');
}
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function tiny_images()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TinyImages')->where('parent_id', null);
}
public function getTotalLikesAttribute()
{
return $this->morphMany('App\Like', 'likeable')->count();
}
public function setUserIdAttribute($value)
{
$this->attributes['user_id'] = \Auth::user()->id;
}
}

@ -1,30 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
use Kalnoy\Nestedset\NodeTrait;
class BlogCategory extends Model
{
use NodeTrait;
public $fillable = ['name_en','name_fa','parent_id'];
public function parent()
{
return $this->belongsTo('App\BlogCategory', 'parent_id');
}
public function children()
{
return $this->hasMany('App\BlogCategory', 'parent_id');
}
public function blogs()
{
return $this->belongsToMany('App\Blog','blog_blog_category');
}
}

@ -1,29 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Brand extends Model
{
protected $fillable = ['name_en','name_fa'];
protected $hidden = ['pivot'];
public function categories()
{
return $this->belongsToMany('App\Category');
}
public function business_items()
{
return $this->hasMany('App\BusinessItem');
}
public function products()
{
return $this->hasMany('App\Product');
}
}

@ -1,279 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
// use Laravel\Scout\Searchable;
// use Conner\Tagging\Taggable;
// use Spatie\Permission\Traits\HasRoles;
// use App\Appended\Traites\UpdateModels;
// use App\Appended\Traites\GetDateAttributesTrait;
class Business extends Model
{
// use Searchable;
// use Taggable;
// use HasRoles;
// use UpdateModels;
// use GetDateAttributesTrait;
protected $guard_name = 'web';
protected $fillable = [
'verification', 'main_type', 'category_id', 'business_title_id', 'brand_en', 'brand_fa',
'slug', 'full_name', 'features', 'details', 'about', 'user_id', 'marketer_id',
'perpose', 'city_id', 'district_id', 'payment_methods', 'free_shipping_for', 'latitude', 'longitude',
'phones', 'special_page',
'template_id', 'rate'
];
public function likedThis()
{
if (auth()->check() && $this->likes()->get()) {
foreach ($this->likes()->get() as $like) {
if (auth()->user()->id === $like->user_id)
return true;
}
return false;
}
return false;
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function setFeaturesAttribute($value)
{
$this->attributes['features'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function setPhonesAttribute($value)
{
$this->attributes['phones'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getPhonesAttribute()
{
return json_decode($this->attributes['phones']);
}
public function getDetailsAttribute()
{
$details = json_decode($this->attributes['details']);
if ($details and isset($details->PaymentMethods)) {
$configMethods = config('SPconf.PaymentMethods');
$methods = [];
foreach ($details->PaymentMethods as $PaymentMethod) {
if (array_has($configMethods, $PaymentMethod)) {
$methods[$PaymentMethod] = $configMethods[$PaymentMethod];
}
}
$details->PaymentMethods = $methods;
}
return $details;
}
public function getFeaturesAttribute()
{
return json_decode($this->attributes['features']);
}
public function business_items()
{
return $this->hasMany('App\BusinessItem');
}
public function verified_business_items()
{
return $this->hasMany('App\BusinessItem')->where('verification', 1);
}
public function portfolios()
{
return $this->hasMany('App\Portfolio');
}
public function contact_messages()
{
return $this->hasMany('App\ContactMessage');
}
public function reservations()
{
return $this->hasMany('App\Reservation');
}
public function business_title()
{
return $this->belongsTo('App\BusinessTitle');
}
public function addresses()
{
return $this->morphMany('App\Address', 'addressable');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function categories()
{
return $this->belongsToMany('App\Category')->withTimestamps();
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function shopping_carts()
{
return $this->hasMany('App\ShoppingCart');
}
public function orders()
{
return $this->hasMany('App\Order');
}
public function city()
{
return $this->belongsTo('App\City');
}
public function district()
{
return $this->belongsTo('App\District');
}
public function data()
{
return $this->hasMany('App\Data');
}
public function template()
{
return $this->hasMany('App\SpUserTemplate');
}
public function user_templates()
{
return $this->hasMany('App\SpUserTemplate');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function news()
{
return $this->hasMany('App\News');
}
public function likes()
{
return $this->morphMany('App\Like', 'likeable');
}
public function toSearchableArray()
{
return [
'id' => $this->id,
'brand_en' => $this->brand_en,
'brand_fa' => $this->brand_fa,
'city_id' => $this->city_id,
];
}
/**
* Get all of the post's comments.
*/
public function comments()
{
return $this->morphMany('App\Comment', 'commentable')->orderBy('updated_at', 'desc');
}
public function feedbacks()
{
return $this->morphMany('App\Feedback', 'feedbackable')->orderBy('updated_at', 'desc');
}
public function members()
{
return $this->belongsToMany('App\user', 'business_has_user', 'business_id', 'user_id');
}
public function orginalImages()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function files()
{
return $this->hasMany('App\Gallery')->where('parent_id', null);
}
public function gallery()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null);
}
public function orginalLogo()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null);
}
public function logo()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null);
}
public function orginalBanner()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner')->where('parent_id', null);
}
public function banner()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner')->where('parent_id', null);
}
public function special_content_options()
{
return $this->morphMany('App\SpecialContentOption', 'special_content_optionable');
}
public function social_media()
{
return $this->hasOne('App\SocialMedia');
}
public function events()
{
return $this->hasMany('App\Event');
}
public function attributes()
{
return $this->belongsToMany('App\Attribute');
}
}

@ -1,186 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
//use Conner\Tagging\Taggable;
use App\Appended\Traites\GetDateAttributesTrait;
class BusinessItem extends Model
{
// use Taggable;
use GetDateAttributesTrait;
protected $appends = ['image_path'];
protected $fillable = [
'status',///???
'description',
'rate',//????
'price',//???
'price_2',//???
'category_id',
'business_id',//????
'user_id',//???
'brand_id',
'city_id',
'district_id',
'product_id',
'name',
'sale_type',
'used',//???
'thumbnail',
'details',
'title',//???
'verification'//???
];
public function category()
{
return $this->belongsTo('App\Category');
}
public function brand()
{
return $this->belongsTo('App\Brand');
}
public function city()
{
return $this->belongsTo('App\City');
}
public function district()
{
return $this->belongsTo('App\District');
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function product()
{
return $this->belongsTo('App\Product');
}
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
public function feedbacks()
{
return $this->morphMany('App\Feedback', 'feedbackable')->orderBy('updated_at', 'desc');
}
public function offer()
{
return $this->hasMany('App\Offer');
}
public function first_variation()
{
return $this->hasOne('App\BusinessItemVariation');
}
public function business_item_variations()
{
return $this->hasMany('App\BusinessItemVariation');
}
public function user_frames()
{
return $this->morphToMany('App\\SpUserFrame', 'element', 'sp_user_elements');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function gallery()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
}
public function likes()
{
return $this->morphMany('App\Like', 'likeable');
}
public function gifts()
{
return $this->hasMany('App\Gift', 'business_item_self_id');
}
public function special_content_options()
{
return $this->morphMany('App\SpecialContentOption', 'special_content_optionable');
}
public function getDescriptionAttribute()
{
if ($this->product && $this->product->detail && $this->product->detail->description) {
return $this->product->detail->description . "\n" . $this->attributes['description'];
} else {
return $this->attributes['description'];
}
}
public function getThumbnailAttribute()
{
if ($this->title_image->isNotEmpty()) {
return $this->title_image->first()->path;
} elseif ($this->product() && $this->product && $this->product->title_image->first()) {
return $this->product->title_image->first()->path;
}
return 'WM-Main/Assets/NoPreview/preview.png';
}
public function getImagePathAttribute()
{
if ($this->title_image->isNotEmpty()) {
return $this->title_image->first()->path;
} elseif ($this->product() && $this->product && $this->product->title_image->first()) {
return $this->product->title_image->first()->path;
}
return 'WM-Main/Assets/NoPreview/preview.png';
}
public function setDetailLink($value)
{
$this->linkToDetail = "{$value}/{$this->id}";
}
public function options()
{
return $this->belongsToMany('App\Option');
}
}

@ -1,51 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BusinessItemVariation extends Model
{
protected $fillable = ['price','price_2','stock','description','business_item_id', 'num_sold', 'num_in_shopping'];
public function business_item ()
{
return $this->belongsTo('App\BusinessItem');
}
public function shopping_carts ()
{
return $this->morphMany('App\ShoppingCart', 'payable');
}
public function offers ()
{
return $this->hasMany('App\Offer');
}
public function orders ()
{
return $this->hasMany('App\Order');
}
public function auction ()
{
return $this->hasOne('App\Auction');
}
public function business ()
{
return $this->belongsTo('App\Business');
}
public function getDescriptionAttribute ()
{
return json_decode($this->attributes['description']);
}
public function setDescriptionAttribute ($value)
{
$this->attributes['description'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}

@ -1,38 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\UpdateModels;
class BusinessTitle extends Model
{
use UpdateModels;
protected $fillable=['name_fa','name_en','category_id','details'];
public function business()
{
return $this->hasMany('App\Business');
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
protected function clearCacheItems(){
Cache::forget('business_title');
}
}

@ -1,122 +0,0 @@
<?php
namespace App;
//use App\Appended\Traites\UpdateModels;
use Illuminate\Database\Eloquent\Model;
use Kalnoy\Nestedset\NodeTrait;
class Category extends Model
{
// use UpdateModels;
use NodeTrait;
protected $fillable = ['name_en','business_id', 'name_fa', 'type', 'slug', 'sipping_wight', 'language', 'priority', 'parent_id', 'additional_attributes', 'additional_view', 'specification_fields'];
protected $hidden = ['pivot'];
public function parent()
{
return $this->belongsTo('App\Category', 'parent_id');
}
public function business_title()
{
return $this->hasMany('App\BusinessTitle');
}
public function attributes()
{
return $this->hasMany('App\Attribute');
}
public function order_variation()
{
return $this->belongsToMany('App\Attribute')->where('for_section', 'Order');
}
public function children()
{
return $this->hasMany('App\Category', 'parent_id');
}
public function products()
{
return $this->hasMany('App\Product');
}
public function brands()
{
return $this->belongsToMany('App\Brand');
}
public function business_categories()
{
return $this->belongsToMany('App\Business');
}
public function business()
{
return $this->hasMany('App\Business');
}
public function business_items()
{
return $this->hasMany('App\BusinessItem');
}
public function templates()
{
return $this->hasMany('App\SpTemplate');
}
public function user_templates()
{
return $this->hasManyThrough('App\SpUserTemplate', 'App\SpTemplate', 'category_id', 'sp_template_id', 'id', 'id');
}
//////////////
public function c_attributes()
{
return $this->belongsToMany('App\Attribute', 'attribute_category');
}
public function news()
{
return $this->belongsToMany('App\News');
}
public function businesses()
{
return $this->belongsToMany('App\Business');
}
public function portfolios()
{
return $this->hasMany('App\Portfolio');
}
public function shipping_groups()
{
return $this->belongsToMany('App\ShippingGroup');
}
public function shipping_group_business()
{
return $this->belongsToMany('App\ShippingGroup')->where('business_id', session('ActiveBusiness'));
}
//override action methods and delete caches
protected function clearCacheItems()
{
// dd('rrrr/rrrrun');
Cache::forget('main_categories');
}
protected function updateRelatedFiles()
{
}
}

@ -1,12 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CategoryTempBusiness extends Model
{
public $timestamps = false;
protected $fillable = ['category_id', 'temp_business_id'];
}

@ -1,10 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ChatMessage extends Model{
protected $fillable=['sender_id','receiver_id','title','text','is_seen'];
}

@ -1,68 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\UpdateModels;
use Kalnoy\Nestedset\NodeTrait;
class City extends Model
{
use UpdateModels;
use NodeTrait;
protected $fillable=['name_fa', 'name_en', 'type', 'capital_city', 'latitude', 'longitude', 'parent_id'];
public function addresses ()
{
return $this->hasMany('App\Address');
}
public function business_items ()
{
return $this->hasMany('App\BusinessItem');
}
public function businesss ()
{
return $this->hasMany('App\Business');
}
public function districts ()
{
return $this->hasMany('App\District');
}
public function destination_orders ()
{
return $this->hasMany('App\Orders', 'destination_city_id');
}
public function source_orders ()
{
return $this->hasMany('App\Orders', 'source_city_id');
}
public function parent()
{
return $this->belongsTo('App\City', 'parent_id');
}
public function children()
{
return $this->hasMany('App\City', 'parent_id');
}
public function cities ()
{
return $this->hasMany('App\City', 'parent_id');
}
public function province ()
{
return $this->belongsTo('App\City', 'parent_id');
}
protected function clearCacheItems(){
Cache::forget('cities');
}
}

@ -1,38 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Client extends Model
{
protected $fillable = ['name', 'cell_number', 'birth_date', 'business_id'];
public $timestamps = false;
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->created_at = $model->freshTimestamp();
});
}
public function setBirthDateAttribute($value)
{
if ($value) {
$this->attributes['birth_date'] = \Carbon\Carbon::createFromFormat('Y-m-d', $value)->toDateTimeString();
}
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
}

@ -1,25 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesPersianTrait;
class Comment extends Model
{
use GetDateAttributesPersianTrait;
protected $fillable = ['text', 'user_id', 'commentable_id', 'commentable_type'];
public function user()
{
return $this->belongsTo('App\User')->select(['id','name']);
}
public function commentable()
{
return $this->morphTo();
}
}

@ -1,25 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ContactMessage extends Model
{
protected $fillable = ['business_id', 'subject', 'name', 'email', 'phone_number', 'text', 'data'];
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDataAttribute()
{
return json_decode($this->attributes['data']);
}
public function business()
{
return $this->belongsTo('App\Business');
}
}

@ -1,30 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Conversation extends Model
{
public $fillable = [
'user_one_id',
'user_two_id',
'status',
'withUser'
];
public function messages()
{
return $this->hasMany('App\Message');
}
public function userone()
{
return $this->belongsTo('App\User', 'user_one_id')->select('id', 'name', 'last_activity');
}
public function usertwo()
{
return $this->belongsTo('App\User', 'user_two_id')->select('id', 'name', 'last_activity');
}
}

@ -1,38 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\App;
use Kalnoy\Nestedset\NodeTrait;
use Carbon\Carbon;
class Cooperation extends Model
{
protected $table = 'cooperation';
public $fillable = ['user_id','status','comments','other','append_job' , 'created_at' , 'updated_at'];
public function User()
{
return $this->belongsTo('App\User')->select(['name','id','detail','birthday','cell_number','email']);
}
public function FormData()
{
return $this->hasMany('App\CooperationData', 'type_id')
->where('model_type' , 'App\Cooperation');
}
public function UserData()
{
return $this->hasMany('App\CooperationData', 'type_id')->where('model_type' , 'App\\User');
}
public function setAppointmentAttribute($value)
{
$carbon = new Carbon();
$date = substr($value, 0, -3);
$date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString();
$this->attributes['appointment'] = $date;
}
}
?>

@ -1,34 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CooperationData extends Model
{
// protected $table = 'cooperation_data';
protected $table = 'data_cooperation';
public $fillable = ['type_id','type','data' , 'model_type'];
public function getDataAttribute()
{
return json_decode($this->attributes['data']);
}
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public static function getFormData($model_id,$model_type){
$coop = CooperationData::where('model_type' , $model_type)->where('type_id' , $model_id);
if ($coop->get()){
return $coop->get();
}return [];
}
public static function lgn($value){
$ex = explode ('Common_',$value);
if (count ($ex) > 1){
return trans ("validation.attributes.{$ex[1]}");
}
return trans ("validation.attributes.{$value}");
}
}

@ -1,41 +0,0 @@
<?php
namespace App;
use App\Appended\Traites\GetDateAttributesTrait;
use Carbon\Carbon;
use Carbon\CarbonPeriod;
use Illuminate\Database\Eloquent\Model;
class CRMEvent extends Model
{
public $fillable = ['eventable_id', 'eventable_type', 'title', 'text', 'date' , 'property'];
protected $table = 'crm_events';
public function user()
{
return $this->belongsTo('App\User')->select(['id', 'name']);
}
public function getDateAttribute()
{
$carbon = new Carbon($this->attributes['date']);
return $carbon;
}
public function setDateAttribute($value)
{
$carbon = new Carbon();
$date = substr($value, 0, -3);
$date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString();
$this->attributes['date'] = $date;
}
public function setPropertyAttribute($value){
$this->attributes['property'] = json_encode($value);
}
public function getPropertyAttribute(){
return json_decode($this->attributes['property']);
}
public function setUserIdAttribute(){
$this->attributes['user_id'] = auth()->user()->id;
}
}

@ -1,21 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Data extends Model
{
protected $table='data';
protected $fillable=['name_en','name_fa'];
public function element()
{
return $this->hasOne('App\Element');
}
public function business()
{
return $this->belongsTo('App\Business');
}
}

@ -1,30 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\UpdateModels;
class District extends Model
{
use UpdateModels;
protected $fillable=['name_fa','city_id','type'];
public function city ()
{
return $this->belongsTo('App\City');
}
public function business_items ()
{
return $this->hasMany('App\BusinessItem');
}
public function businesss ()
{
return $this->hasMany('App\Business');
}
}

@ -1,21 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class EmplQuestion extends Model
{
/**
* @return mixed
*/
public function getQuestionsListAttribute()
{
return json_decode($this->attributes['questions_list']);
}
public function setQuestionsListAttribute($value)
{
$this->attributes['questions_list'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}

@ -1,29 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class EmplResults extends Model
{
protected $fillable = [
'question_id' , 'result' , 'user_id'
];
public function getResultAttribute()
{
return json_decode($this->attributes['result']);
}
public function setResultAttribute($value)
{
$this->attributes['result'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function Question()
{
return $this->belongsTo('App\EmplQuestion','question_id');
}
public function User()
{
return $this->belongsTo('App\User','user_id')->select(['name','id','detail','birthday','cell_number','email']);
}
}

@ -1,45 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class Event extends Model
{
// use GetDateAttributesTrait;
public $fillable = ['type', 'title_fa', 'body','business_id'];
public function banner()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner')->where('parent_id', null);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function business()
{
return $this->belongsTo('App\Business');
}
}

@ -1,25 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Faq extends Model
{
protected $fillable=['title','description','faq_category_id'];
public function faq_category() {
return $this->belongsTo('App\FaqCategory');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function tiny_images()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TinyImages')->where('parent_id', null);
}
}

@ -1,15 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class FaqCategory extends Model
{
protected $fillable=['name_fa','name_en'];
public function faqs() {
return $this->hasMany('App\Faq');
}
}

@ -1,27 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class Feedback extends Model
{
use GetDateAttributesTrait;
protected $fillable = ['text','rate'];
protected $table = 'feedbacks';
public function feedbackable()
{
return $this->morphTo();
}
public function author()
{
/// Select ID , Name , ProfilePhoto
/// Change By Saleh
return $this->belongsTo('App\User','author_id')->select(['id','name']);
}
}

@ -1,15 +0,0 @@
<?php
namespace App;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class Finance extends Model
{
use GetDateAttributesTrait;
protected $fillable = [
'agreedprice', 'marketershare','title','marketer_id','taskowner', 'financable_id', 'financable_type','paidprice'
];
}

@ -1,99 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gallery extends Model
{
protected $fillable = ['user_id', 'business_id', 'marketer_business_id', 'name', 'path', 'crop_data', 'test'];
public $timestamps = false;
public $casts = ['crop_data' => 'array'];
public function usages()
{
return $this->hasMany('App\Uploadable', 'gallery_id', 'id');
}
public function roles()
{
return $this->hasMany('App\Uploadable', 'gallery_id', 'id');
}
public function parent()
{
return $this->belongsTo('App\Gallery', 'parent_id');
}
public function children()
{
return $this->hasMany('App\Gallery', 'parent_id', 'id');
}
public function businessitem()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function business_item()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function business_items()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function businessRole($role = 'Gallery')
{
return $this->morphedByMany('App\Business', 'uploadable')->wherePivot('image_role', $role);
}
public function portfolios()
{
return $this->morphedByMany('App\Portfolio', 'uploadable');
}
public function portfolio()
{
return $this->morphedByMany('App\Portfolio', 'uploadable');
}
public function projects()
{
return $this->morphedByMany('App\Project', 'uploadable');
}
public function project()
{
return $this->morphedByMany('App\Project', 'uploadable');
}
public function product()
{
return $this->morphedByMany('App\Product', 'uploadable');
}
public function frames()
{
return $this->morphedByMany('App\SpUserFrame', 'uploadable');
}
public function elements()
{
return $this->morphedByMany('App\SpUserElement', 'uploadable');
}
public function business()
{
return $this->belongsTo('App\Business', 'business_id', 'id');
}
public function getImageRoleAttribute()
{
return $this->pivot->image_role;
}
}

@ -1,90 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class GalleryLast extends Model
{
protected $fillable = ['user_id', 'business_id', 'marketer_business_id', 'name', 'path', 'crop_data', 'test'];
public $timestamps = false;
public $casts = ['crop_data' => 'array'];
public function usages()
{
return $this->hasMany('App\UploadableLast', 'gallery_id', 'id');
}
public function roles()
{
return $this->hasMany('App\UploadableLast', 'gallery_id', 'id');
}
public function parent()
{
return $this->belongsTo('App\GalleryLast', 'parent_id');
}
public function children()
{
return $this->hasMany('App\GalleryLast', 'parent_id', 'id');
}
public function businessitem()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function business_item()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function business_items()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function businessRole($role = 'Gallery')
{
return $this->morphedByMany('App\Business', 'uploadable')->wherePivot('image_role', $role);
}
public function portfolios()
{
return $this->morphedByMany('App\Portfolio', 'uploadable');
}
public function portfolio()
{
return $this->morphedByMany('App\Portfolio', 'uploadable');
}
public function product()
{
return $this->morphedByMany('App\Product', 'uploadable');
}
public function frames()
{
return $this->morphedByMany('App\SpUserFrame', 'uploadable');
}
public function elements()
{
return $this->morphedByMany('App\SpUserElement', 'uploadable');
}
public function business()
{
return $this->belongsTo('App\Business', 'business_id', 'id');
}
public function getImageRoleAttribute()
{
return $this->pivot->image_role;
}
}

@ -1,90 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class GalleryNew extends Model
{
protected $fillable = ['user_id', 'business_id', 'marketer_business_id', 'name', 'path', 'crop_data', 'test'];
public $timestamps = false;
public $casts = ['crop_data' => 'array'];
public function usages()
{
return $this->hasMany('App\UploadableNew', 'gallery_id', 'id');
}
public function roles()
{
return $this->hasMany('App\UploadableNew', 'gallery_id', 'id');
}
public function parent()
{
return $this->belongsTo('App\GalleryNew', 'parent_id');
}
public function children()
{
return $this->hasMany('App\GalleryNew', 'parent_id', 'id');
}
public function businessitem()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function business_item()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function business_items()
{
return $this->morphedByMany('App\BusinessItem', 'uploadable');
}
public function businessRole($role = 'Gallery')
{
return $this->morphedByMany('App\Business', 'uploadable')->wherePivot('image_role', $role);
}
public function portfolios()
{
return $this->morphedByMany('App\Portfolio', 'uploadable');
}
public function portfolio()
{
return $this->morphedByMany('App\Portfolio', 'uploadable');
}
public function product()
{
return $this->morphedByMany('App\Product', 'uploadable');
}
public function frames()
{
return $this->morphedByMany('App\SpUserFrame', 'uploadable');
}
public function elements()
{
return $this->morphedByMany('App\SpUserElement', 'uploadable');
}
public function business()
{
return $this->belongsTo('App\Business', 'business_id', 'id');
}
public function getImageRoleAttribute()
{
return $this->pivot->image_role;
}
}

@ -1,14 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gift extends Model
{
public $timestamps = false;
public function business_item()
{
return $this->belongsTo('App\BusinessItem');
}
}

@ -1,24 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Help extends Model
{
protected $fillable=['title_fa','title_en','text','help_category_id'];
public function help_category()
{
return $this->belongsTo('App\HelpCategory','help_category_id');
}
public function tiny_images()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TinyImages')->where('parent_id', null);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable')->where('parent_id', null);
}
}

@ -1,16 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class HelpCategory extends Model
{
protected $fillable=['name_fa','name_en'];
public function helps()
{
return $this->hasMany('App\Help');
}
}

@ -1,13 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Language extends Model{
public function user_template()
{
return $this->hasMany('App\\SpUserTemplate','default_language_id');
}
}

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Like extends Model
{
public $timestamps = false;
/**
* Get all of the owning likeable models.
*/
public function likeable()
{
return $this->morphTo();
}
}

@ -1,40 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Message extends Model
{
public $fillable = [
'message',
'is_seen',
'deleted_from_sender',
'deleted_from_receiver',
'user_id',
'conversation_id',
];
protected $visible = [
'id', 'message', 'is_seen', 'created_at', 'user_id'
];
public function getHumansTimeAttribute()
{
$date = $this->created_at;
$now = $date->now();
return $date->diffForHumans($now, true);
}
public function conversation()
{
return $this->belongsTo('App\Conversation');
}
public function user()
{
return $this->belongsTo('App\User');
}
}

@ -1,90 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class News extends Model
{
use GetDateAttributesTrait;
public $fillable = ['title_fa', 'body', 'summary'];
public function categories()
{
// return $this->belongsToMany('App\Category');
return $this->belongsToMany('App\Category', 'category_news', 'news_id', 'category_id');
}
public function user_frames()
{
return $this->morphToMany('App\\SpUserFrame', 'element', 'sp_user_elements');
}
public function business()
{
return $this->belongsTo('App\Business');
// return $this->belongsToMany('App\Category','category_news','news_id','category_id');
}
public function files()
{
return $this->morphMany('App\Upload', 'uploadable')->select('id', 'uploadable_id', 'uploadable_type', 'user_id', 'path');
}
public function gallery()
{
return $this->morphMany('App\Upload', 'uploadable')->where('file_role', 1);
}
/**
* Get all of the post's comments.
*/
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function tiny_images()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TinyImages')->where('parent_id', null);
}
public function getThumbnailAttribute()
{
if ($this->title_image->isNotEmpty()) {
return $this->title_image->first()->path;
}
return 'WM-Main/Assets/NoPreview/preview.png';
}
public function setDetailLink($value)
{
$this->linkToDetail = "{$value}/{$this->id}";
}
}

@ -1,19 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Offer extends Model
{
protected $fillable = ['offer','actual_value','type', 'business_item_variation_id', 'proposer_id', 'status'];
public function user()
{
return $this->belongsTo('App\User','proposer_id');
}
public function business_item_variation()
{
return $this->belongsTo('App\BusinessItemVariation');
}
}

@ -1,24 +0,0 @@
<?php
// this is comment in address
namespace App;
use Illuminate\Database\Eloquent\Model;
class Option extends Model
{
protected $fillable = ['name', 'slug', 'parent_id', 'price'];
public $timestamps = false;
public function business_items()
{
return $this->belongsToMany('App\BusinessItem');
}
public function values()
{
return $this->hasMany('App\Option', 'parent_id');
}
}

@ -1,66 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class Order extends Model
{
use GetDateAttributesTrait;
protected $fillable = ['transaction_id','description', 'status', 'shipping_free', 'address_id', 'buyer_id','business_id', 'shipping_method','status_logs', 'details'];
public function address ()
{
return $this->belongsTo('App\Address');
}
public function buyer ()
{
return $this->belongsTo('App\User', 'buyer_id');
}
public function business ()
{
return $this->belongsTo('App\Business', 'business_id');
}
public function transactions ()
{
return $this->belongsTo('App\Transaction');
}
public function order_items()
{
return $this->hasMany('App\OrderItem');
}
public function setStatusLogsAttribute($value)
{
$this->attributes['status_logs'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getStatusLogsAttribute()
{
return json_decode($this->attributes['status_logs']);
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
// public function getCreatedAtAttribute($date)
// {
// return \Morilog\Jalali\jDate::forge($date)->format('datetime');
// }
}

@ -1,51 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class OrderItem extends Model
{
protected $fillable = ['order_id', 'shipping_method_id','quantity','payable_id','payable_type', 'price', 'details', 'auction_id', 'gift_id'];
public function auction()
{
return $this->belongsTo('App\Auction');
}
public function business_item_variation()
{
return $this->belongsTo('App\BusinessItemVariation');
}
public function order()
{
return $this->belongsTo('App\Order');
}
public function getCreatedAtAttribute($date)
{
return \Morilog\Jalali\jDate::forge($date)->format('datetime');
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
public function getAllPriceAttribute()
{
return $this->attributes['price'] * $this->attributes['quantity'];
}
public function payable()
{
return $this->morphTo();
}
}

@ -1,13 +0,0 @@
<?php
namespace App;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Model;
class Payment extends Model
{
public $fillable = ['payment', 'user_id', ' finance_id', 'description'];
}

@ -1,14 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Permission extends Model
{
protected $fillable=['name','guard_name'];
// public function roles()
// {
// return $this->belongsToMany('App\Role');
// }
}

@ -1,62 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Portfolio extends Model
{
protected $fillable = [
'title', 'description', 'category_id', 'business_id', 'path' , 'data_class'
];
public function business()
{
return $this->belongsTo('App\Business');
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function gallery()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function getThumbnailAttribute()
{
if ($this->title_image->isNotEmpty()) {
return $this->title_image->first()->path;
}
return 'WM-Main/Assets/NoPreview/preview.png';
}
public function setDetailLink($value)
{
$this->linkToDetail = "{$value}/{$this->id}";
}
}

@ -1,32 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
// auther changed to author.
protected $fillable = ['text','author_id','business_item_id','product_id'];
public function author ()
{
return $this->belongsTo('App\User');
}
public function business_item ()
{
return $this->belongsTo('App\BusinessItem');
}
public function product ()
{
return $this->belongsTo('App\Product');
}
public function user_frames()
{
return $this->morphToMany('App\\SpUserFrame', 'element', 'sp_user_elements');
}
}

@ -1,98 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
class Product extends Model
{
use Searchable;
protected $fillable = ['model_fa', 'model_en', 'rate', 'brand_id', 'slug', 'category_id', 'pros', 'cons', 'user_id'];
protected $hidden = [
'variations',
];
public function detail()
{
return $this->belongsTo('App\ProductDetail', 'product_detail_id');
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
public function feedbacks()
{
return $this->morphMany('App\Feedback', 'feedbackable')->orderBy('updated_at', 'desc');
}
public function brand()
{
return $this->belongsTo('App\Brand');
}
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
}
public function files()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function gallery()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
}
public function likes()
{
return $this->morphMany('App\Like', 'likeable');
}
public function toSearchableArray()
{
return [
'id' => $this->id,
'model_en' => $this->model_en,
'model_fa' => $this->model_fa,
'description' => $this->description,
'author_id' => $this->author_id,
'brand_id' => $this->brand_id,
'slug' => $this->slug,
'category_id' => $this->category_id,
];
}
public function special_content_options()
{
return $this->morphMany('App\SpecialContentOption', 'special_content_optionable');
}
}

@ -1,16 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ProductDetail extends Model {
protected $fillable = ['variations'
];
public function products()
{
return $this->hasMany( 'App\Product' );
}
}

@ -1,98 +0,0 @@
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Project extends Model
{
protected $fillable = [
'temp_business_id',
'project_type',
'description',
'begin_date',
'end_date',
'special_features'
];
public function responsible_person()
{
return $this->belongsToMany('App\User')->wherePivot('type', 'Responsible');
}
public function marketer()
{
return $this->belongsToMany('App\User')->wherePivot('type', 'Marketer');
}
public function users()
{
return $this->belongsToMany('App\User');
}
public function temp_business()
{
return $this->belongsTo('App\TempBusiness', 'temp_business_id', 'id')->select(['id', 'brand_fa', 'brand_en', 'details', 'phones', 'created_at', 'business_id']);
}
public function comments()
{
return $this->morphMany('App\Comment', 'commentable')->with('user')->select(["id", "text", "commentable_id", "commentable_type", "user_id", "created_at"]);
}
public function Events()
{
return $this->morphMany('App\CrmEvent', 'eventable')->with('user')
->select(["id", "title", "text", "date", "user_id" ,"property", "created_at"]);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function gallery()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
}
public function setSpecialFeaturesAttribute($value)
{
$this->attributes['special_features'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getSpecialFeaturesAttribute()
{
return json_decode($this->attributes['special_features']);
}
public function setBeginDateAttribute($value)
{
$carbon = new Carbon();
$date = substr($value, 0, -3);
$date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString();
$this->attributes['begin_date'] = $date;
}
public function setEndDateAttribute($value)
{
if (!is_null($value)){
$carbon = new Carbon();
$date = substr($value, 0, -3);
$date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString();
$this->attributes['end_date'] = $date;
}else{
$this->attributes['end_date'] = $value;
}
}
// public function getBeginDateAttribute()
// {
// return jdate( $this->attributes['begin_date'])->format('y/m/d').' | '.jdate( $this->attributes['begin_date'])
// ->ago();
// }
// public function getEndDateAttribute()
// {
// return jdate( $this->attributes['end_date'])->format('y/m/d');
// }
}

@ -1,15 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Promotion extends Model
{
public function files()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
}

@ -1,22 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Reservation extends Model
{
protected $fillable = ['business_id', 'user_id', 'name', 'description', 'time', 'date'];
public function business()
{
return $this->belongsTo('App\Business');
}
public function user()
{
return $this->belongsTo('App\User');
}
}

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
protected $fillable=[
'name','name_fa','guard_name'
];
// public function permissions()
// {
// return $this->belongsToMany('App\Permission');
// }
}

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RollCall extends Model
{
protected $fillable=[
'date','check_in_time','check_out_time','description','user_id','ip','exit_ip', 'type'
];
public function getDateFaAttribute()
{
return \Morilog\Jalali\CalendarUtils::strftime('Y/m/d', strtotime($this->attributes['date']));
}
}

@ -1,21 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Section extends Model
{
protected $fillable=['name_en','name_fa'];
public function elements()
{
return $this->hasMany('App\Element');
}
public function template()
{
return $this->belongsTo('App\Template');
}
}

@ -1,26 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ShippingGroup extends Model
{
protected $fillable = ['name', 'description', 'business_id', 'min_value_for_free'];
public $timestamps = false;
public function shipping_rules()
{
return $this->hasMany('App\ShippingRule');
}
public function categories()
{
return $this->belongsToMany('App\Category');
}
public function shipping_methods()
{
return $this->belongsToMany('App\ShippingMethod');
}
}

@ -1,22 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ShippingMethod extends Model
{
protected $fillable = ['name_fa', 'name_en'];
public function shipping_groups()
{
return $this->belongsToMany('App\ShippingGroup');
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
}

@ -1,30 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ShippingRule extends Model
{
protected $fillable = ['type', 'shipping_group_id', 'shipping_method_id', 'price', 'exceptions'];
public function shipping_group()
{
return $this->belongsTo('App\ShippingGroup');
}
public function getExceptionsAttribute()
{
return json_decode($this->attributes['exceptions']);
}
public function setExceptionsAttribute($value)
{
if ($value !== null) {
$this->attributes['exceptions'] = json_encode($value, JSON_UNESCAPED_UNICODE);
} else {
$this->attributes['exceptions'] = null;
}
}
}

@ -1,48 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
class ShoppingCart extends Model
{
use GetDateAttributesTrait, SoftDeletes;
protected $fillable = ['quantity', 'user_id', 'payable_id', 'payable_type', 'details', 'business_id'];
public function batch()
{
return $this->belongsTo('App\BatchShoppingCart');
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details'], true);
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function user()
{
return $this->belongsTo('App\User');
}
public function business_item_variation()
{
return $this->belongsTo('App\BusinessItemVariation');
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function payable()
{
return $this->morphTo();
}
}

@ -1,11 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SimpleMessage extends Model
{
}

@ -1,29 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Site extends Model
{
public $timestamps = false;
public function user_template()
{
return $this->belongsTo('App\SpUserTemplate', 'sp_user_template_id');
}
public function site_config()
{
return $this->hasOne('App\SiteConfig');
}
public function getSiteConfigDefaultOtherAttribute()
{
if (isset($this->site_config->other)) {
return $this->site_config->other;
} else {
return \App\SiteConfig::whereNull('other')->first()->other;
}
}
}

@ -1,82 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SiteConfig extends Model
{
protected $fillable = [
'site_id', 'gateway_data', 'e_namad_data', 'sms', 'seo', 'contact_us', 'other'
];
public $timestamps = false;
public function site()
{
return $this->belongsTo('App\Site');
}
public function getGatewayDataAttribute()
{
return json_decode($this->attributes['gateway_data']);
}
public function setGatewayDataAttribute($value)
{
$this->attributes['gateway_data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getSmsAttribute()
{
return json_decode($this->attributes['sms']);
}
public function getENamadDataAttribute()
{
return json_decode($this->attributes['e_namad_data']);
}
public function setENamadDataAttribute($value)
{
$this->attributes['e_namad_data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function setSmsAttribute($value)
{
$this->attributes['sms'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getSeoAttribute()
{
return json_decode($this->attributes['seo']);
}
public function setSeoAttribute($value)
{
$this->attributes['seo'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getContactUsAttribute()
{
return json_decode($this->attributes['contact_us']);
}
public function setContactUsAttribute($value)
{
$this->attributes['contact_us'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getOtherAttribute()
{
$other = json_decode($this->attributes['other']);
$other = ($other) ? $other : collect() ;
$other->LoginColor = (isset($other->LoginColor)) ? $other->LoginColor : 'Cyan';
$other->LoginImage = (isset($other->LoginImage)) ? $other->LoginImage : 'WM-WebBuilder/Assets/Images/LoginPage.jpg';
$other->RegisterationColor = (isset($other->RegisterationColor)) ? $other->RegisterationColor : 'Red';
$other->SMSValidationColor = (isset($other->SMSValidationColor)) ? $other->SMSValidationColor : 'Orange';
$other->ForgotPasswordColor = (isset($other->ForgotPasswordColor)) ? $other->ForgotPasswordColor : 'Purple';
$other->ResetPasswordVerificationColor = (isset($other->ResetPasswordVerificationColor)) ? $other->ResetPasswordVerificationColor : 'Black';
$other->ResetPasswordColor = (isset($other->ResetPasswordColor)) ? $other->ResetPasswordColor : 'Black';
$other->ManagementHeaderImg = (isset($other->ManagementHeaderImg)) ? $other->ManagementHeaderImg : 'WM-Main/Assets/Uploads/Backgrounds/Admin-BG1.jpg';
$other->LoaderAddress = (isset($other->LoaderAddress)) ? $other->LoaderAddress : null;
$other->EmptyShoppingCart = (isset($other->EmptyShoppingCart)) ? $other->EmptyShoppingCart : (object) ['URL' => 'WM-Common/Assets/AnimatedIcons/Flower-Once.gif', 'Class' => ''];
$other->EmptyBusinessItem = (isset($other->EmptyBusinessItem)) ? $other->EmptyBusinessItem : (object) ['URL' => 'WM-Common/Assets/AnimatedIcons/Flower-Once.gif', 'Class' => ''];
return $other;
}
public function setOtherAttribute($value)
{
$this->attributes['other'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}

@ -1,31 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesPersianTrait;
class SmsPanel extends Model {
use GetDateAttributesPersianTrait;
protected $fillable = ['user_id','business_id','content','quantity','cell_number', 'type'];
public $timestamps = false;
public function user()
{
return $this->belongsTo('App\User');
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function getTypeFaAttribute()
{
$type = config('WM-Conf.SMSPanelType');
return isset($type[$this->attributes['type']]) ? $type[$this->attributes['type']] : 'دیگر';
}
}

@ -1,17 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SocialMedia extends Model
{
protected $fillable = ['business_id', 'telegram', 'instagram'];
public $timestamps = false;
public function business()
{
return $this->hasOne('App\Business');
}
}

@ -1,24 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpFacility extends Model{
public function templates()
{
return $this->belongsToMany('App\SpTemplate','facility_template','facility_id','template_id');
}
public function user_facilities()
{
return $this->hasMany('App\\SpUserFacility');
}
public function facility_type()
{
return $this->belongsTo('App\\SpFacilityType', 'sp_facility_type_id');
}
}

@ -1,14 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpFacilityType extends Model{
public function facility()
{
return $this->hasMany('App\SpFacility');
}
}

@ -1,96 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Classes\Specials\Assets\Traits\StaticData;
class SpFrame extends Model
{
use StaticData;
protected $fillable = ['name_en', 'name_fa', 'description', 'sp_template_id', 'user_id',
'sp_section_id', 'path', 'frame_info', 'action', 'sp_frame_type_id',
'resource', 'customizable', 'responsibility', 'detail_info', 'action_name_fa', 'is_global', 'section', 'type', 'sp_page_id','visibility_level'
];
public function template()
{
return $this->belongsTo('App\SpTemplate', 'sp_template_id');
}
public function user_pages()
{
return $this->belongsToMany('App\SpUserPage', 'sp_user_frames', 'sp_user_page_id', 'sp_frame_id');
}
public function page()
{
return $this->belongsTo('App\SpPage', 'sp_page_id');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function files()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function frame_type()
{
return $this->belongsTo('App\SpFrameType', 'sp_frame_type_id');
}
public function getThumbnailAttribute()
{
if ($this->title_image->isNotEmpty()) {
return $this->title_image[0]->path;
}
return 'WM-Main/Assets/NoPreview/preview.png';
}
public function getTypeAttribute()
{
return $this->frame_type->type;
}
public function scopeSection($query, $frameTypeId, $masterPageId)
{
return $query->where('sp_page_id', $masterPageId)->where('sp_frame_type_id', $frameTypeId);
}
public function getFrameInfoAttribute($value)
{
return json_decode($value, true);
}
public function setFrameInfoAttribute($value)
{
$this->attributes['frame_info'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function users()
{
return $this->belongsToMany('App\User', 'sp_frame_user')->withPivot('action')->withTimestamps();
}
public function user_frames()
{
return $this->hasMany('App\\SpUserFrame', 'sp_frame_id');
}
}

@ -1,25 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpFrameType extends Model{
public $timestamps = false;
public function dependent_page()
{
return $this->belongsTo('App\\SpPageType', 'dependent_page_type_id');
}
public function getFrameInfoFormAttribute($value)
{
return json_decode($value, true);
}
public function setFrameInfoFormAttribute($value)
{
$this->attributes['frame_info_form'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}

@ -1,22 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpLink extends Model
{
public $timestamps = false;
public function linkable()
{
return $this->morphTo();
}
public function page()
{
return $this->belongsTo('App\\SpUserPage', 'page_id');
}
}

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpMasterTemplate extends Model{
public $timestamps = false;
protected $fillable = ['name_en', 'relative_path'];
public function templates(){
return $this->hasMany('App\\SpTemplate');
}
}

@ -1,26 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpPage extends Model{
protected $fillable = ['name_en', 'name_fa', 'sp_template_id'];
public function template()
{
return $this->belongsTo('App\SpTemplate');
}
public function frames()
{
return $this->hasMany('App\SpFrame', 'sp_page_id');
}
public function user_pages()
{
return $this->hasMany('App\SpUserPage');
}
}

@ -1,16 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpPageType extends Model{
public $timestamps = false;
public function required_frames()
{
return $this->belongsToMany('App\SpFrameType', 'page_type_has_frame_type', 'sp_page_type_id', 'sp_frame_type_id');
}
}

@ -1,31 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpSection extends Model{
protected $fillable = ['name_en', 'name_fa', 'description', 'sp_page_id', 'editable'];
public function page()
{
return $this->belongsTo('App\SpPage','sp_page_id','id');
}
public function allowed_frames()
{
return $this->hasMany('App\SpFrame','sp_section_id','id');
}
public function frames()
{
return $this->belongsToMany('App\SpFrame','sp_user_frames','sp_section_id','sp_frame_id');
}
public function user_frames()
{
return $this->hasMany('App\SpUserFrame','sp_section_id','id');
}
}

@ -1,80 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpTemplate extends Model
{
protected $fillable = ['name_en', 'name_fa', 'description', 'category_id', 'sp_master_template_id', 'user_id', 'rtl', 'ltr'];
public function pages()
{
return $this->hasMany('App\SpPage');
}
public function first_page()
{
return $this->hasOne('App\SpPage');
}
public function frames()
{
return $this->hasMany('App\SpFrame');
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function user_templates()
{
return $this->hasMany('App\SpUserTemplate');
}
public function facilities()
{
return $this->belongsToMany('App\SpFacility', 'facility_template', 'template_id', 'facility_id');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function files()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function master_template()
{
return $this->belongsTo('App\\SpMasterTemplate', 'sp_master_template_id');
}
public function getRtlAttribute($value) {
return json_decode($value, true);
}
public function getLtrAttribute($value) {
return json_decode($value, true);
}
// public function files()
// {
// return $this->morphToMany('App\Gallery', 'uploadable');
// }
}

@ -1,53 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Classes\Specials\Assets\Traits\StaticImage;
use App\Appended\Classes\Specials\Assets\Traits\StaticLink;
use App\Appended\Classes\Specials\Assets\Traits\SetStaticData;
class SpUserElement extends Model {
use StaticImage, SetStaticData, StaticLink;
public $timestamps = false;
public function business_item() {
return $this->belongsTo('App\BusinessItem', 'element_id')->where('element_type', '=', 'App\BusinessItem');
}
public function categories()
{
return $this->belongsTo('App\BusinessItem', 'element_id')->where('element_type', '=', 'App\Category');
}
public function userFrame() {
return $this->belongsTo('App\SpUserFrame', 'sp_user_frame_id');
}
public function images() {
return $this->morphToMany('App\Gallery', 'uploadable')->withPivot('id', 'image_role');
}
public function links()
{
return $this->morphMany('App\SpLink', 'linkable');
}
public function getDataAttribute($value)
{
return json_decode($value, true);
}
public function getLanguageIdAttribute() {
return $this->userFrame->language_id;
}
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}

@ -1,21 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpUserFacility extends Model{
protected $fillable = [
'sp_user_template_id', 'sp_facility_id', 'is_enable'
];
public function facility()
{
return $this->belongsTo('App\\SpFacility');
}
public function user_template()
{
return $this->belongsTo('App\\SpUserTemplate');
}
}

@ -1,134 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Classes\Specials\Assets\Traits\StaticImage;
use App\Appended\Classes\Specials\Assets\Traits\StaticLink;
use App\Appended\Classes\Specials\Assets\Traits\SetStaticData;
class SpUserFrame extends Model{
use StaticImage, SetStaticData, StaticLink;
// protected $with = ['frame'];
protected $fillable =['sp_frame_id', 'business_id', 'data', 'language_id'];
public $timestamps = false;
public function business(){
return $this->belongsTo('App\\Business');
}
public function frame()
{
return $this->belongsTo('App\\SpFrame','sp_frame_id');
}
public function parent()
{
return $this->belongsTo('App\\SpUserFrame', 'parent_id');
}
public function children()
{
return $this->hasMany('App\\SpUserFrame', 'parent_id');
}
public function user_pages()
{
return $this->belongsToMany('App\SpUserPage', 'user_page_frame')->withPivot('frame_order');
}
public function business_items()
{
return $this->morphedByMany('App\\BusinessItem', 'element', 'sp_user_elements');
}
public function news()
{
return $this->morphedByMany('App\\News', 'element', 'sp_user_elements');
}
public function categories()
{
return $this->morphedByMany('App\\Category', 'element', 'sp_user_elements');
}
public function posts()
{
return $this->morphedByMany('App\\Post', 'element', 'sp_user_elements');
}
public function products()
{
return $this->morphedByMany('App\\Product', 'element', 'sp_user_elements');
}
public function elements()
{
return $this->hasMany('App\\SpUserElement', 'sp_user_frame_id')->orderBy('element_order');
}
public function links()
{
return $this->morphMany('App\SpLink', 'linkable');
}
public function images()
{
return $this->morphToMany('App\Gallery','uploadable')->withPivot('image_role');
}
public function scopeSection($query, $frameTypeId, $userTemplateId, $masterPageId, $languageId)
{
return $query->where('language_id', $languageId)->where('sp_user_template_id', $userTemplateId)
->whereHas('frame', function ($q1) use ($frameTypeId, $masterPageId) {
$q1->where('sp_page_id', $masterPageId)->where('sp_frame_type_id', $frameTypeId);
});
}
public function language()
{
return $this->belongsTo('App\\Language', 'language_id');
}
/*******************************************************
accessors and mutators
*******************************************************/
public function getDataAttribute($value)
{
return json_decode($value, true);
}
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getFrameOrderAttribute()
{
return $this->pivot->frame_order;
}
public function getThumbnailAttribute()
{
if ($this->frame->title_image->isNotEmpty()) {
return $this->frame->title_image[0]->path;
}
return 'WM-Main/Assets/NoPreview/preview.png';
}
public function getTypeAttribute()
{
return $this->frame->frame_type->type;
}
public function getNameEnAttribute()
{
return $this->frame->name_en;
}
public function getNameFaAttribute()
{
return $this->frame->name_fa;
}
}

@ -1,90 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpUserPage extends Model{
protected $fillable = ['name_en', 'name_fa', 'description', 'sp_user_template_id', 'sp_page_id', 'business_id', 'sp_page_type_id', 'language_id'];
public function user_template()
{
return $this->belongsTo('App\SpUserTemplate','sp_user_template_id');
}
public function page()
{
return $this->belongsTo('App\SpPage', 'sp_page_id');
}
public function frames()
{
return $this->belongsToMany('App\SpFrame','sp_user_frames');
}
public function user_frames()
{
return $this->belongsToMany('App\SpUserFrame', 'user_page_frame')->withPivot('frame_order');
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function page_type()
{
return $this->belongsTo('App\SpPageType', 'sp_page_type_id');
}
public function language()
{
return $this->belongsTo('App\Language', 'language_id');
}
public function scopePageType($query, $templateId, $languageId, $pageResponsibility, $pageType = '')
{
return $query->select('id', 'name_en', 'name_fa', 'sp_page_type_id', 'description')
->where('sp_user_template_id', $templateId)
->where('language_id', $languageId)
->whereHas('page_type', function($q) use ($pageType, $pageResponsibility) {
$q->where('responsibility', $pageResponsibility)->where('type', $pageType);
});
}
}

@ -1,78 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpUserTemplate extends Model{
public $timestamps = null;
protected $fillable = ['name_fa', 'description', 'sp_template_id', 'business_id','default_language_id'];
public function parent()
{
return $this->belongsTo('App\SpUserTemplate', 'parent_id');
}
public function children()
{
return $this->hasMany('App\SpUserTemplate', 'parent_id');
}
public function template()
{
return $this->belongsTo('App\SpTemplate', 'sp_template_id');
}
public function pages()
{
return $this->belongsToMany('App\SpPage','sp_user_pages');
}
public function user_pages()
{
return $this->hasMany('App\SpUserPage');
}
public function home_page()
{
return $this->hasOne('App\SpUserPage')->where('name_en', 'Home');
}
public function business()
{
return $this->belongsTo('WM\\Core\\Models\\VirtualActivity');
}
public function user_facilities()
{
return $this->hasMany('App\SpUserFacility');
}
public function facilities()
{
return $this->belongsToMany('App\\SpFacility', 'sp_user_facilities', 'sp_user_template_id', 'sp_facility_id');
}
public function images() {
return $this->morphToMany( 'App\Gallery', 'uploadable' );
}
public function title_image() {
return $this->morphToMany( 'App\Gallery', 'uploadable' )->wherePivot( 'image_role', 'TitleImage' )->where('parent_id', null);;
}
public function gallery() {
return $this->morphToMany( 'App\Gallery', 'uploadable' )->wherePivot( 'image_role', 'Gallery' )->where('parent_id', null);;
}
public function language()
{
return $this->belongsTo('App\Language', 'default_language_id');
}
public function sites()
{
return $this->hasMany('App\Site');
}
}

@ -1,20 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpecialContent extends Model
{
protected $fillable = ['category_id','name_fa', 'name_en', 'has_relation', 'update_js', 'aspect_ratio', 'type','level'];
public function special_content_options()
{
return $this->hasMany('App\SpecialContentOption', 'special_content_id');
}
public function category()
{
return $this->belongsTo('App\Category');
}
}

@ -1,56 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpecialContentOption extends Model
{
protected $fillable = ['name_fa', 'optionable_type', 'optionable_id', 'details', 'special_content_id'];
public function special_content()
{
return $this->belongsTo('App\SpecialContent');
}
// public function getDetailsAttribute()
// {
// return json_decode($this->attributes['details']);
// }
// public function setDetailsAttribute($value)
// {
// $this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
// }
public function optionable()
{
return $this->morphTo();
}
public function files()
{
return $this->morphMany('App\Upload', 'uploadable')->select('id', 'uploadable_id', 'uploadable_type', 'user_id', 'path');
}
public function gallery()
{
return $this->morphMany('App\Upload', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
}
public function orginalTitleImage()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function title_image()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
}

@ -1,19 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Staff extends Model
{
protected $fillable=[
'name','family','role'
];
public function roll_calls()
{
return $this->hasMany('App\RollCall');
}
}

@ -1,24 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Strategy extends Model
{
protected $fillable = [
'user_id', 'category_id', 'topic', 'name_en', 'name_fa', 'text'
];
public function category()
{
return $this->belongsTo('App\Category');
}
public function user()
{
return $this->belongsTo('App\User');
}
}

@ -1,47 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
class Tag extends Model
{
use Searchable;
public $fillable = ['name', 'tag_group', 'type', 'category_id'];
public function businesses()
{
return $this->morphedByMany('App\Business', 'taggable');
}
public function business_items()
{
return $this->morphedByMany('App\BusinessItem', 'taggable');
}
public function products()
{
return $this->morphedByMany('App\Product', 'taggable');
}
public function news()
{
return $this->morphedByMany('App\News', 'taggable');
}
public function events()
{
return $this->morphedByMany('App\Event', 'taggable');
}
public function toSearchableArray()
{
return [
'id' => $this->id,
'name' => $this->name,
];
}
}

@ -1,23 +0,0 @@
<?php
namespace App;
use Conner\Tagging\Contracts\TaggingUtility;
use Illuminate\Database\Eloquent\Model;
use Conner\Tagging\Taggable;
class TagGroup extends Model
{
use Taggable;
public $fillable = ['name'];
// public $timestamps=false;
public function tags()
{
$model = $this->taggingUtility->tagModelString();
return $this->hasMany($model, 'tag_group_id');
}
}

@ -1,78 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
use Carbon\Carbon;
class Task extends Model
{
use GetDateAttributesTrait;
protected $fillable = [
'type', 'description', 'activity', 'status', 'user_id', 'owned_id', 'activity', 'taskable_id', 'taskable_type', 'title', 'date'
];
public function setActivityAttribute($value)
{
$this->attributes['activity'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function setDateAttribute($value)
{
$carbon = new Carbon();
$this->attributes['date'] = $carbon->timestamp($value)->timezone('Asia/Tehran')->toDateTimeString();
}
public function finances()
{
return $this->morphMany('App\Finance', 'financable');
}
public function uploadables()
{
return $this->morphMany('App\Uploadable', 'uploadable');
}
public function gallery()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);;
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function logo()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null);;
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function owner()
{
return $this->belongsTo('App\User', 'owned_id');
}
public function comments()
{
return $this->morphMany('App\Comment', 'commentable')->orderBy('updated_at', 'desc');
}
public function taskable()
{
return $this->morphTo();
}
}

@ -1,76 +0,0 @@
<?php
namespace App;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
class TempBusiness extends Model
{
use GetDateAttributesTrait;
protected $fillable = [
'level','priority','user_id', 'business_id', 'category_id', 'business_title_id', 'brand_en', 'brand_fa', 'marketer_id', 'city_id', 'district_id', 'about', 'advantages', 'disadvantages', 'details', 'activity', 'latitude', 'longitude', 'phones'
];
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
public function getPhonesAttribute()
{
return json_decode($this->attributes['phones']);
}
public function addresses()
{
return $this->morphMany('App\Address', 'addressable');
}
public function comments()
{
return $this->morphMany('App\Comment', 'commentable')->orderBy('updated_at', 'desc');
}
public function categories()
{
return $this->belongsToMany('App\Category');
}
public function uploadables()
{
return $this->morphMany('App\Uploadable', 'uploadable');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function logo()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null);;
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function tasks()
{
return $this->morphMany('App\Task', 'taskable');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function marketer()
{
return $this->belongsTo('App\User','marketer_id');
}
}

@ -1,32 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Transaction extends Model
{
protected $table = 'gateway_transactions';
public function orders()
{
return $this->hasMany('App\Order', 'transaction_id');
}
public function order()
{
return $this->hasOne('App\Order', 'transaction_id');
}
public function user_transaction()
{
return $this->hasMany('App\UserTransaction', 'transaction_id');
}
public function transaction_logs()
{
return $this->hasMany('App\TransactionLog');
}
}

@ -1,18 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class TransactionLog extends Model
{
protected $table = 'gateway_transactions_logs';
public function log()
{
return $this->belongsTo('App\Transaction');
}
}

@ -1,24 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Upload extends Model
{
protected $fillable = ['user_id', 'path', 'file_role', 'uploadable_type'];
/**
* Get all of the owning commentable models.
*/
public function uploadable()
{
return $this->morphTo();
}
public function creator ()
{
return $this->belongsTo('App\User');
}
}

@ -1,26 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Uploadable extends Model
{
protected $fillable = ['uploadable_id', 'uploadable_type', 'gallery_id', 'image_role','test'];
public $timestamps = false;
public function orginalGallery()
{
return $this->belongsTo('App\Gallery')->where('parent_id' , null);
}
public function ThumbGallery()
{
return $this->belongsTo('App\Gallery')->where('parent_id' , '!=' , null);
}
public function gallery()
{
return $this->belongsTo('App\Gallery');
}
}

@ -1,26 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class UploadableLast extends Model
{
protected $fillable = ['uploadable_id', 'uploadable_type', 'gallery_id', 'image_role','test'];
public $timestamps = false;
public function orginalGallery()
{
return $this->belongsTo('App\GalleryLast')->where('parent_id' , null);
}
public function ThumbGallery()
{
return $this->belongsTo('App\GalleryLast')->where('parent_id' , '!=' , null);
}
public function gallery()
{
return $this->belongsTo('App\GalleryLast');
}
}

@ -1,26 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class UploadableNew extends Model
{
protected $fillable = ['uploadable_id', 'uploadable_type', 'gallery_id', 'image_role','test'];
public $timestamps = false;
public function orginalGallery()
{
return $this->belongsTo('App\GalleryNew')->where('parent_id' , null);
}
public function ThumbGallery()
{
return $this->belongsTo('App\GalleryNew')->where('parent_id' , '!=' , null);
}
public function gallery()
{
return $this->belongsTo('App\GalleryNew');
}
}

@ -1,210 +0,0 @@
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use Laravel\Passport\HasApiTokens;
use App\Appended\Traites\GetDateAttributesTrait;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use Carbon\Carbon;
class User extends Authenticatable
{
// use Notifiable, HasRoles, HasApiTokens;
// use GetDateAttributesTrait;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
'cell_number',
'business_id',
'introducer_id',
'last_used_business',
'email_token',
'birthday',
'detail'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
////////////////////////////////////////////// new added /////////////////////////
//
// public function cachedRoles()
// {
// /*$userPrimaryKey = $this->primaryKey;
//
// return Cache::remember($cacheKey, 10, function () {
// return $this->roles()->get();
// }*/
// return $this->roles()->get();
//
// }
//
public function canDo($permission, $requireAll = false)
{
if (is_array($permission)) {
foreach ($permission as $permName) {
$hasPerm = $this->canDo($permName);
if ($hasPerm && !$requireAll) {
return true;
} elseif (!$hasPerm && $requireAll) {
return false;
}
}
return $requireAll;
} else {
foreach ($this->cachedRoles() as $role) {
// Validate against the Permission table
foreach ($role->cachedPermissions() as $perm) {
if (strtolower($permission) == strtolower($perm->title)) {
return true;
}
}
}
}
return false;
}
//
// public function hasRole($name)
// {
// foreach ($this->roles()->get() as $role)
// {
// if (strtolower($role->title)===strtolower($name))
// {
// return true;
// }
// }
// return false;
// }
///////////////////////////////////////////////////////////////////
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function offers()
{
return $this->hasMany('App\Offer');
}
public function shopping_carts()
{
return $this->hasMany('App\ShoppingCart');
}
public function businesses()
{
return $this->hasMany('App\Business');
}
public function business_items()
{
return $this->hasMany('App\BusinessItem');
}
public function feedbacks()
{
return $this->hasMany('App\Feedback');
}
public function active_business()
{
return $this->belongsTo('App\Business', 'last_used_business');
}
public function buys()
{
return $this->hasMany('App\Order', 'buyer_id');
}
public function sells()
{
return $this->hasMany('App\Order', 'seller_id');
}
public function files()
{
return $this->hasMany('App\Gallery')->where('business_id', null);
}
public function orginalProfile()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Profile')->where('parent_id', null);
}
public function Profile()
{
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Profile')->where('parent_id', null);
}
public function addresses()
{
return $this->morphMany('App\Address', 'addressable');
}
public function introducer()
{
return $this->belongsTo('App\User', 'introducer_id', 'id');
}
public function send_conversations()
{
return $this->hasMany('App\Conversation', 'sender_id');
}
public function recieve_conversations()
{
return $this->hasMany('App\Conversation', 'receiver_id');
}
public function reservations()
{
return $this->hasMany('App\Reservation');
}
public function likes()
{
return $this->hasMany('App\Like');
}
// public function files()
// {
// return $this->hasMany()
// }
public static function MakeDetail(){
return json_encode (['NationalCode' , 'ParentName' , 'Educational' , 'PlaceBirth']);
}
public function setBirthdayAttribute($value)
{
$carbon = new Carbon();
$date = substr($value, 0, -3);
$date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString();
$this->attributes['birthday'] = $date;
}
public function frames()
{
return $this->belongsToMany('App\\SpFrame', 'sp_frame_user')->withPivot('action')->withTimestamps();
}
}

@ -1,19 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class UserTransaction extends Model
{
public $fillable = ['user_id','transaction_id','action_type','relation_id','relation_type'];
public function gateway_transaction()
{
return $this->belongsTo('App\Transaction','transaction_id','id');
}
public function order()
{
// return $this
}
}

@ -1,40 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class WmItem extends Model
{
public function ShoppingCarts()
{
return $this->morphMany('App\ShoppingCart', 'payable');
}
public function WmItemsCategory()
{
return $this->belongsTo('App\WmItemsCategory');
}
public function getDetailsAttribute($value)
{
return json_decode($value);
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getPivotDetailsAttribute()
{
return json_decode($this->pivot->details);
}
public function business()
{
return $this->belongsTo('App\Business');
}
}

@ -1,25 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class WmItemsCategory extends Model
{
public function WmItems()
{
return $this->hasMany('App\WmItem');
}
public function getDetailsAttribute($value)
{
return json_decode($value);
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save