Skip to content

Commit

Permalink
Merge pull request #3 from zgabievi/analysis-z9AZJP
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
zgabievi authored Jan 4, 2017
2 parents 585673b + d91bf4b commit 7a7a64b
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 452 deletions.
21 changes: 10 additions & 11 deletions src/Facades/Promocodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

class Promocodes extends Facade
{

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'promocodes';
}
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'promocodes';
}
}
147 changes: 74 additions & 73 deletions src/Model/Promocode.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,77 @@

class Promocode extends Model
{

/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'code',
'reward',
'is_used',
];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'is_used' => 'boolean',
];

/**
* Promocode constructor.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);

$this->table = config('promocodes.table', 'promocodes');
}

/**
* Get the user who owns the promocode.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}

/**
* Query builder to find promocode using code
*
* @param $query
* @param $code
* @return mixed
*/
public function scopeByCode($query, $code)
{
return $query->where('code', $code);
}

/**
* Query builder to find all not used promocodes
*
* @param $query
* @return mixed
*/
public function scopeFresh($query)
{
return $query->where('is_used', false);
}
}
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'code',
'reward',
'is_used',
];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'is_used' => 'boolean',
];

/**
* Promocode constructor.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
parent::__construct($attributes);

$this->table = config('promocodes.table', 'promocodes');
}

/**
* Get the user who owns the promocode.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}

/**
* Query builder to find promocode using code.
*
* @param $query
* @param $code
*
* @return mixed
*/
public function scopeByCode($query, $code)
{
return $query->where('code', $code);
}

/**
* Query builder to find all not used promocodes.
*
* @param $query
*
* @return mixed
*/
public function scopeFresh($query)
{
return $query->where('is_used', false);
}
}
Loading

0 comments on commit 7a7a64b

Please sign in to comment.