Fix Corporate Member
This commit is contained in:
@@ -34,11 +34,7 @@ class CorporateMemberController extends Controller
|
|||||||
})
|
})
|
||||||
->with([
|
->with([
|
||||||
'employeds',
|
'employeds',
|
||||||
'currentPolicy' => function ($policy) use ($corporate_id) {
|
'currentPolicy',
|
||||||
$policy->whereHas('corporatePolicy', function($corporatePolicy) use ($corporate_id) {
|
|
||||||
$corporatePolicy->where('corporate_id', $corporate_id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
->with('currentPlan')
|
->with('currentPlan')
|
||||||
->paginate()
|
->paginate()
|
||||||
|
|||||||
13
app/Models/CorporateManager.php
Normal file
13
app/Models/CorporateManager.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CorporateManager extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'corporate_manager';
|
||||||
|
}
|
||||||
@@ -29,6 +29,14 @@ class CorporatePolicy extends Model
|
|||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $with = [
|
||||||
|
'latestLimitJournal'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'limit_balance'
|
||||||
|
];
|
||||||
|
|
||||||
public function corporate()
|
public function corporate()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Corporate::class);
|
return $this->belongsTo(Corporate::class);
|
||||||
@@ -39,6 +47,11 @@ class CorporatePolicy extends Model
|
|||||||
return $this->morphMany(LimitJournal::class, 'journalable');
|
return $this->morphMany(LimitJournal::class, 'journalable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function latestLimitJournal()
|
||||||
|
{
|
||||||
|
return $this->morphOne(LimitJournal::class, 'journalable')->latestOfMany();
|
||||||
|
}
|
||||||
|
|
||||||
public function setCodeAttribute($value)
|
public function setCodeAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
|
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
|
||||||
@@ -61,7 +74,7 @@ class CorporatePolicy extends Model
|
|||||||
|
|
||||||
public function getLimitBalanceAttribute()
|
public function getLimitBalanceAttribute()
|
||||||
{
|
{
|
||||||
$journal = $this->limitJournals()->latest()->first();
|
$journal = $this->latestLimitJournal;
|
||||||
|
|
||||||
return $journal ? $journal->balance : (!empty($this->total_premi) ? $this->total_premi : "0");
|
return $journal ? $journal->balance : (!empty($this->total_premi) ? $this->total_premi : "0");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,19 @@ class DummyMemberSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
User::create([
|
$userEmails = [
|
||||||
'email' => 'admin@linksehat.dev',
|
'admin@linksehat.dev',
|
||||||
'password' => Hash::make('password')
|
'manager+one@gmail.com',
|
||||||
]);
|
'manager+two@gmail.com'
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($userEmails as $email) {
|
||||||
|
User::updateOrCreate([
|
||||||
|
'email' => $email
|
||||||
|
], [
|
||||||
|
'email' => $email,
|
||||||
|
'password' => Hash::make('password')
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,6 +398,16 @@ export default function Corporates() {
|
|||||||
? fCurrency(row.current_policy?.minimal_deposit_net)
|
? fCurrency(row.current_policy?.minimal_deposit_net)
|
||||||
: '-'}
|
: '-'}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Corporate Limit
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
:{' '}
|
||||||
|
{row.current_policy
|
||||||
|
? fCurrency(row.current_policy?.limit_balance)
|
||||||
|
: '-'}
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ export default function Router() {
|
|||||||
{
|
{
|
||||||
path: 'claims/create',
|
path: 'claims/create',
|
||||||
element: <ClaimsCreate />
|
element: <ClaimsCreate />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'claims/:id',
|
||||||
|
element: <ClaimsCreate />
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user