add budgets
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class Admin extends Authenticatable
|
||||
{
|
||||
@@ -155,4 +156,15 @@ class Admin extends Authenticatable
|
||||
{
|
||||
return $this->hasOne(UserHasCabang::class, 'user_id')->with('cabang');
|
||||
}
|
||||
|
||||
public static function getUserByRoleName($roleName)
|
||||
{
|
||||
$role = Role::where('name', $roleName)->first();
|
||||
|
||||
if ($role) {
|
||||
return $role->users()->with('cabang')->get();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BudgetControl extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'budget_control';
|
||||
protected $fillable = [
|
||||
'cabang_id',
|
||||
'sender_id',
|
||||
'receiver_id',
|
||||
'amount',
|
||||
'remarks',
|
||||
'periode_month',
|
||||
'periode_year',
|
||||
'transferred_at',
|
||||
'closing_at',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'user_id');
|
||||
}
|
||||
|
||||
public function cabang()
|
||||
{
|
||||
return $this->belongsTo(Cabang::class, 'cabang_id');
|
||||
}
|
||||
|
||||
public function sender()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'sender_id');
|
||||
}
|
||||
|
||||
public function receiver()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'receiver_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class BudgetControlLog extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'budget_control_log';
|
||||
protected $fillable = [
|
||||
'cabang_id',
|
||||
'sender_id',
|
||||
'receiver_id',
|
||||
'amount',
|
||||
'remarks',
|
||||
'periode_month',
|
||||
'periode_year',
|
||||
'transferred_at',
|
||||
'closing_at',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'user_id');
|
||||
}
|
||||
|
||||
public function cabang()
|
||||
{
|
||||
return $this->belongsTo(Cabang::class, 'cabang_id');
|
||||
}
|
||||
|
||||
public function sender()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'sender_id');
|
||||
}
|
||||
|
||||
public function receiver()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'receiver_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user