Skip to content
Permalink
Browse files

Normalize use of attributes property and constructor across all models

  • Loading branch information...
lovett committed Sep 19, 2019
1 parent 6d5f7ef commit a635f686be0c0189b081dd9b51aeb25e00da0a4e
Showing with 26,706 additions and 17,295 deletions.
  1. +1 −0 .gitignore
  2. +17 −0 app/Client.php
  3. +17 −0 app/Estimate.php
  4. +12 −9 app/Invoice.php
  5. +17 −0 app/Project.php
  6. +17 −0 app/Tag.php
  7. +22 −4 app/Time.php
  8. +17 −0 app/User.php
  9. +320 −772 public/css/app.css
  10. +26,266 −16,510 public/js/app.js
@@ -2,6 +2,7 @@
._*
.\#*
\#*
.ac-php-conf.json
/build
/node_modules
/public/hot
@@ -21,6 +21,13 @@ class Client extends Model
{
use SoftDeletes, Search;
/**
* Default values for newly-created instances.
*
* @var array
*/
protected $attributes = [];
/**
* Fields that can be used for searching.
*
@@ -126,6 +133,16 @@ function ($join) {
return $builder;
}
/**
* Set instance defaults.
*
* @param array $attributes The key-value array to populate.
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
/**
* At-a-glance numbers that summarize a client in various ways.
*/
@@ -19,6 +19,13 @@ class Estimate extends Model
{
use SoftDeletes, Search;
/**
* Default values for newly-created instances.
*
* @var array
*/
protected $attributes = [];
/**
* Map of states an estimate can be assigned to a human-readable label.
*
@@ -100,6 +107,16 @@ public static function listing(Builder $builder)
return $builder;
}
/**
* Set instance defaults.
*
* @param array $attributes The key-value array to populate.
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
/**
* Users associated with the client.
*
@@ -226,21 +226,24 @@ public static function listing(Builder $builder)
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$now = new Carbon();
$this->attributes = [
'sent' => $now,
'start' => $now->copy()->subDays(30),
'end' => $now,
'due' => $now->copy()->addDays(30),
'amount' => 0,
];
$this->attributes = array_merge(
$this->attributes,
[
'sent' => $now,
'start' => $now->copy()->subDays(30),
'end' => $now,
'due' => $now->copy()->addDays(30),
'amount' => 0,
],
);
while ($this->due->isWeekend()) {
$this->due = $this->due->addDays(1);
}
parent::__construct($attributes);
}
@@ -20,6 +20,13 @@ class Project extends Model
{
use SoftDeletes, Search;
/**
* Default values for newly-created instances.
*
* @var array
*/
protected $attributes = [];
/**
* Fields that can be used for searching.
*
@@ -100,6 +107,16 @@ class Project extends Model
'lastActive',
];
/**
* Set instance defaults.
*
* @param array $attributes The key-value array to populate.
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
/**
* Custom accessor for allottedTotalMinutes specified in hours
*
@@ -10,6 +10,13 @@
class Tag extends Model
{
/**
* Default values for newly-created instances.
*
* @var array
*/
protected $attributes = [];
/**
* This model does not have created_at and updated_at fields.
*
@@ -24,6 +31,16 @@ class Tag extends Model
*/
protected $fillable = ['name'];
/**
* Set instance defaults.
*
* @param array $attributes The key-value array to populate.
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
/**
* Time entries associated with a tag.
*/
@@ -29,10 +29,7 @@ class Time extends Model
*
* @var array
*/
protected $attributes = [
'minutes' => 0,
'billable' => true,
];
protected $attributes = [];
/**
* When a time entry is updated, mark its project as updated as well.
@@ -147,6 +144,27 @@ public static function listing(Builder $builder)
return $builder;
}
/**
* Set instance defaults.
*
* @param array $attributes The key-value array to populate.
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$now = new Carbon();
$this->attributes = array_merge(
$this->attributes,
[
'start' => $now,
'minutes' => 0,
'billable' => true,
]
);
}
/**
* Query scope to restrict to in-progress, unfinished records.
*
@@ -17,6 +17,13 @@ class User extends Authenticatable
{
use Notifiable, AsMenu;
/**
* Default values for newly-created instances.
*
* @var array
*/
protected $attributes = [];
/**
* The database table used by the model.
*
@@ -55,6 +62,16 @@ class User extends Authenticatable
'updated_at',
];
/**
* Set instance defaults.
*
* @param array $attributes The key-value array to populate.
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
}
/**
* Clients associated with the user.
*

0 comments on commit a635f68

Please sign in to comment.
You can’t perform that action at this time.