Project.php 1.31 KB
Newer Older
beardedwarrior's avatar
beardedwarrior committed
1 2 3 4 5 6
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/**
 * App\Project
 *
 * @property int $id
 * @property string $payment_id
 * @property string $target_amount
 * @property string $status
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Deposit[] $deposits
 * @property-read mixed $amount_received
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Project wherePaymentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereTargetAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereUpdatedAt($value)
 * @mixin \Eloquent
 */
beardedwarrior's avatar
beardedwarrior committed
26 27 28 29 30 31 32
class Project extends Model
{
    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function deposits()
    {
33
        return $this->hasMany(Deposit::class, 'payment_id', 'payment_id');
beardedwarrior's avatar
beardedwarrior committed
34
    }
35 36 37 38

    public function getAmountReceivedAttribute() {
        return $this->deposits->sum('amount');
    }
beardedwarrior's avatar
beardedwarrior committed
39
}