From 458ee4ee3e8a1add1a337cb92ce8a357d0b7926c Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Mon, 3 Jun 2019 06:27:03 +0700 Subject: [PATCH] add model, define model --- app/Models/Kelas.php | 26 ++++++++++++ app/Models/Keuangan.php | 30 +++++++++++++ app/Models/Role.php | 26 ++++++++++++ app/Models/Siswa.php | 42 +++++++++++++++++++ app/Models/Tabungan.php | 29 +++++++++++++ app/Models/Tagihan.php | 32 ++++++++++++++ app/Models/Transaksi.php | 34 +++++++++++++++ .../2019_06_02_221144_create_kelas.php | 2 +- .../2019_06_02_221204_create_siswa.php | 16 +++---- .../2019_06_02_221209_create_tagihan.php | 4 +- .../2019_06_02_221214_create_transaksi.php | 6 +-- .../2019_06_02_221221_create_keuangan.php | 6 +-- .../2019_06_02_221229_create_tabungan.php | 2 +- 13 files changed, 237 insertions(+), 18 deletions(-) create mode 100644 app/Models/Kelas.php create mode 100644 app/Models/Keuangan.php create mode 100644 app/Models/Role.php create mode 100644 app/Models/Siswa.php create mode 100644 app/Models/Tabungan.php create mode 100644 app/Models/Tagihan.php create mode 100644 app/Models/Transaksi.php diff --git a/app/Models/Kelas.php b/app/Models/Kelas.php new file mode 100644 index 0000000..53aedaa --- /dev/null +++ b/app/Models/Kelas.php @@ -0,0 +1,26 @@ +hasMany('App\Models\Siswa','kelas_id','id'); + } + + public function periode(){ + return $this->hasOne('App\Models\Periode','id','periode_id'); + } +} diff --git a/app/Models/Keuangan.php b/app/Models/Keuangan.php new file mode 100644 index 0000000..d07a45b --- /dev/null +++ b/app/Models/Keuangan.php @@ -0,0 +1,30 @@ +hasOne('App\Models\Tabungan','id','tabungan_id'); + } + + public function transaksi(){ + return $this->hasOne('App\Models\Transaksi','id','transaksi_id'); + } +} diff --git a/app/Models/Role.php b/app/Models/Role.php new file mode 100644 index 0000000..ced027f --- /dev/null +++ b/app/Models/Role.php @@ -0,0 +1,26 @@ +hasOne('App\Models\Siswa','id','siswa_id'); + } + + public function tagihan(){ + return $this->hasOne('App\Models\Tagihan','id','tagihan_id'); + } +} diff --git a/app/Models/Siswa.php b/app/Models/Siswa.php new file mode 100644 index 0000000..dcc4ec9 --- /dev/null +++ b/app/Models/Siswa.php @@ -0,0 +1,42 @@ +hasOne('App\Models\Kelas','id','kelas_id'); + } + + public function transaksi(){ + return $this->hasMany('App\Models\Transaksi','siswa_id','id'); + } + + public function role(){ + return $this->hasMany('App\Models\Role','siswa_id','id'); + } + + public function tabungan(){ + return $this->hasMany('App\Models\Tabungan','siswa_id','id'); + } +} diff --git a/app/Models/Tabungan.php b/app/Models/Tabungan.php new file mode 100644 index 0000000..6e731c5 --- /dev/null +++ b/app/Models/Tabungan.php @@ -0,0 +1,29 @@ +belongsTo('App\Models\Siswa','id','siswa_id'); + } + + public function keuangan(){ + return $this->hasOne('App\Models\Keuangan','tabungan_id','id'); + } +} diff --git a/app/Models/Tagihan.php b/app/Models/Tagihan.php new file mode 100644 index 0000000..d4bad19 --- /dev/null +++ b/app/Models/Tagihan.php @@ -0,0 +1,32 @@ +hasMany('App\Models\Transaksi','tagihan_id','id'); + } + + public function role(){ + return $this->hasMany('App\Models\Role','tagihan_id','id'); + } + + public function siswa(){ + return $this->belongsToMany('App\Models\Siswa','role'); + } +} diff --git a/app/Models/Transaksi.php b/app/Models/Transaksi.php new file mode 100644 index 0000000..937522b --- /dev/null +++ b/app/Models/Transaksi.php @@ -0,0 +1,34 @@ +hasOne('App\Models\Tagihan','id','tagihan_id'); + } + + public function siswa(){ + return $this->hasOne('App\Models\Siswa','id','siswa_id'); + } + + public function keuangan(){ + return $this->hasOne('App\Models\Keuangan','transaksi_id','id'); + } +} diff --git a/database/migrations/2019_06_02_221144_create_kelas.php b/database/migrations/2019_06_02_221144_create_kelas.php index c2adaea..e9e39dc 100644 --- a/database/migrations/2019_06_02_221144_create_kelas.php +++ b/database/migrations/2019_06_02_221144_create_kelas.php @@ -15,7 +15,7 @@ class CreateKelas extends Migration { Schema::create('kelas', function (Blueprint $table) { $table->bigIncrements('id'); - $table->integer('periode_id'); + $table->integer('periode_id')->nullable(); $table->string('nama'); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2019_06_02_221204_create_siswa.php b/database/migrations/2019_06_02_221204_create_siswa.php index 54bd0fd..3c32792 100644 --- a/database/migrations/2019_06_02_221204_create_siswa.php +++ b/database/migrations/2019_06_02_221204_create_siswa.php @@ -17,14 +17,14 @@ class CreateSiswa extends Migration $table->bigIncrements('id'); $table->integer('kelas_id'); $table->string('nama'); - $table->string('tempat_lahir'); - $table->date('tanggal_lahir'); - $table->enum('jenis_kelamin', ['L', 'P']); - $table->text('alamat'); - $table->string('nama_wali'); - $table->string('telp_wali'); - $table->string('pekerjaan_wali'); - $table->boolean('is_yatim'); + $table->string('tempat_lahir')->nullable(); + $table->date('tanggal_lahir')->nullable(); + $table->enum('jenis_kelamin', ['L', 'P'])->nullable(); + $table->text('alamat')->nullable(); + $table->string('nama_wali')->nullable(); + $table->string('telp_wali')->nullable(); + $table->string('pekerjaan_wali')->nullable(); + $table->boolean('is_yatim')->nullable(); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/migrations/2019_06_02_221209_create_tagihan.php b/database/migrations/2019_06_02_221209_create_tagihan.php index 29b2523..0ba56e2 100644 --- a/database/migrations/2019_06_02_221209_create_tagihan.php +++ b/database/migrations/2019_06_02_221209_create_tagihan.php @@ -17,8 +17,8 @@ class CreateTagihan extends Migration $table->bigIncrements('id'); $table->string('nama'); $table->double('jumlah'); - $table->boolean('wajib_semua'); - $table->integer('kelas_id'); + $table->boolean('wajib_semua')->nullable(); + $table->integer('kelas_id')->nullable(); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/migrations/2019_06_02_221214_create_transaksi.php b/database/migrations/2019_06_02_221214_create_transaksi.php index 9fa0529..bebfe1c 100644 --- a/database/migrations/2019_06_02_221214_create_transaksi.php +++ b/database/migrations/2019_06_02_221214_create_transaksi.php @@ -17,9 +17,9 @@ class CreateTransaksi extends Migration $table->bigIncrements('id'); $table->integer('siswa_id'); $table->integer('tagihan_id'); - $table->integer('diskon'); - $table->boolean('is_lunas'); - $table->text('keterangan'); + $table->integer('diskon')->nullable(); + $table->boolean('is_lunas')->nullable(); + $table->text('keterangan')->nullable(); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/migrations/2019_06_02_221221_create_keuangan.php b/database/migrations/2019_06_02_221221_create_keuangan.php index f7a3a85..79abe95 100644 --- a/database/migrations/2019_06_02_221221_create_keuangan.php +++ b/database/migrations/2019_06_02_221221_create_keuangan.php @@ -15,12 +15,12 @@ class CreateKeuangan extends Migration { Schema::create('keuangan', function (Blueprint $table) { $table->bigIncrements('id'); - $table->integer('tabungan_id'); - $table->integer('transaksi_id'); + $table->integer('tabungan_id')->nullable(); + $table->integer('transaksi_id')->nullable(); $table->enum('tipe', ['in','out']); $table->double('jumlah'); $table->double('total_kas'); - $table->text('keterangan'); + $table->text('keterangan')->nullable(); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/migrations/2019_06_02_221229_create_tabungan.php b/database/migrations/2019_06_02_221229_create_tabungan.php index 929a52a..a7b885c 100644 --- a/database/migrations/2019_06_02_221229_create_tabungan.php +++ b/database/migrations/2019_06_02_221229_create_tabungan.php @@ -19,7 +19,7 @@ class CreateTabungan extends Migration $table->enum('tipe', ['in','out']); $table->double('jumlah'); $table->double('saldo'); - $table->text('keperluan'); + $table->text('keperluan')->nullable(); $table->timestamps(); $table->softDeletes(); });