diff --git a/app/Entities/Invoices/Invoice.php b/app/Entities/Invoices/Invoice.php index b6a44bb..6120b1d 100755 --- a/app/Entities/Invoices/Invoice.php +++ b/app/Entities/Invoices/Invoice.php @@ -13,26 +13,62 @@ use Illuminate\Database\Eloquent\Model; */ class Invoice extends Model { + /** + * The attributes that aren't mass assignable. + * + * @var array + */ protected $guarded = ['id', 'created_at', 'updated_at']; + /** + * The attributes that should be cast to native types. + * + * @var array + */ protected $casts = ['items' => 'array']; + + /** + * The number of models to return for pagination. + * + * @var int + */ protected $perPage = 25; + /** + * Get the route key for the model. + * + * @return string + */ public function getRouteKeyName() { return 'number'; } + /** + * Invoice belongs to project. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function project() { return $this->belongsTo(Project::class); } + /** + * Invoice belongs to creator (user). + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function creator() { return $this->belongsTo(User::class); } + /** + * Generate invoice (incrementing) number. + * + * @return string + */ public function generateNewNumber() { $prefix = date('ym'); @@ -49,13 +85,21 @@ class Invoice extends Model return $prefix.'001'; } - public function getItemsCountAttribute($value) + /** + * Get invoice items count attribute. + * + * @return int + */ + public function getItemsCountAttribute() { - $pcsCount = 0; - return count($this->items); } + /** + * Get invoice number in html link format. + * + * @return \Illuminate\Support\HtmlString + */ public function numberLink() { return link_to_route('invoices.show', $this->number, [$this->number], [ diff --git a/app/Entities/Options/Option.php b/app/Entities/Options/Option.php index ba5004b..7a65f3f 100755 --- a/app/Entities/Options/Option.php +++ b/app/Entities/Options/Option.php @@ -6,7 +6,24 @@ use Illuminate\Database\Eloquent\Model; class Option extends Model { + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = ['key', 'value']; + + /** + * The table associated with the model. + * + * @var string + */ protected $table = 'site_options'; + + /** + * Indicates if the model should be timestamped. + * + * @var bool + */ public $timestamps = false; } diff --git a/app/Entities/Partners/Customer.php b/app/Entities/Partners/Customer.php index 0c0dc9f..72ec4fc 100644 --- a/app/Entities/Partners/Customer.php +++ b/app/Entities/Partners/Customer.php @@ -6,28 +6,58 @@ use Illuminate\Database\Eloquent\Model; class Customer extends Model { + /** + * The attributes that are mass assignable. + * + * @var array + */ protected $fillable = ['name', 'email', 'phone', 'pic', 'address', 'website', 'notes', 'is_active']; + /** + * Customer has many projects. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function projects() { return $this->hasMany('App\Entities\Projects\Project'); } + /** + * Customer morph many payments. + * + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ public function payments() { return $this->morphMany('App\Entities\Payments\Payment', 'partner'); } + /** + * Customer has many subscriptions. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function subscriptions() { return $this->hasMany('App\Entities\Subscriptions\Subscription'); } + /** + * Customer has many invoices through their projects. + * + * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough + */ public function invoices() { return $this->hasManyThrough('App\Entities\Invoices\Invoice', 'App\Entities\Projects\Project'); } + /** + * Get customer name in html link format. + * + * @return \Illuminate\Support\HtmlString + */ public function nameLink() { return link_to_route('customers.show', $this->name, [$this->id], [ @@ -38,11 +68,21 @@ class Customer extends Model ]); } + /** + * Get customr status attribute. + * + * @return string + */ public function getStatusAttribute() { return $this->is_active == 1 ? trans('app.active') : trans('app.in_active'); } + /** + * Get customr status label attribute. + * + * @return string + */ public function getStatusLabelAttribute() { $color = $this->is_active == 1 ? ' style="background-color: #337ab7"' : '';