Changeset View
Changeset View
Standalone View
Standalone View
src/app/Transaction.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
/** | |||||
* The eloquent definition of a Transaction. | |||||
* | |||||
* @property int $amount | |||||
* @property string $description | |||||
* @property string $id | |||||
* @property string $object_id | |||||
* @property string $object_type | |||||
* @property string $type | |||||
* @property string $transaction_id | |||||
* @property string $user_email | |||||
*/ | |||||
class Transaction extends Model | class Transaction extends Model | ||||
{ | { | ||||
protected $fillable = [ | protected $fillable = [ | ||||
// actor, if any | // actor, if any | ||||
'user_email', | 'user_email', | ||||
// entitlement, wallet | // entitlement, wallet | ||||
'object_id', | 'object_id', | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | class Transaction extends Model | ||||
public function toString() | public function toString() | ||||
{ | { | ||||
$label = $this->objectTypeToLabelString() . '-' . $this->{'type'}; | $label = $this->objectTypeToLabelString() . '-' . $this->{'type'}; | ||||
return \trans("transactions.{$label}", $this->toArray()); | return \trans("transactions.{$label}", $this->toArray()); | ||||
} | } | ||||
public function shortDescription() | |||||
{ | |||||
$label = $this->objectTypeToLabelString() . '-' . $this->{'type'} . '-short'; | |||||
return \trans("transactions.{$label}", $this->toArray()); | |||||
} | |||||
public function wallet() | public function wallet() | ||||
{ | { | ||||
if ($this->object_type !== \App\Wallet::class) { | if ($this->object_type !== \App\Wallet::class) { | ||||
return null; | return null; | ||||
} | } | ||||
return \App\Wallet::where('id', $this->object_id)->first(); | return \App\Wallet::where('id', $this->object_id)->first(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |