add model, define model

pull/1/head
Aji Kamaludin 6 years ago
parent 4a08bd5e70
commit 458ee4ee3e
No known key found for this signature in database
GPG Key ID: 23E2BDC458317AF8

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Kelas extends Model
{
use SoftDeletes;
protected $table = 'kelas';
protected $fillable = [
'periode_id',
'nama'
];
public function siswa(){
return $this->hasMany('App\Models\Siswa','kelas_id','id');
}
public function periode(){
return $this->hasOne('App\Models\Periode','id','periode_id');
}
}

@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Keuangan extends Model
{
use SoftDeletes;
protected $table = 'keuangan';
protected $fillable = [
'tabungan_id',
'transaksi_id',
'tipe',
'jumlah',
'total_kas',
'keterangan',
];
public function tabungan(){
return $this->hasOne('App\Models\Tabungan','id','tabungan_id');
}
public function transaksi(){
return $this->hasOne('App\Models\Transaksi','id','transaksi_id');
}
}

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Role extends Model
{
use SoftDeletes;
protected $table = 'role';
protected $fillable = [
'tagihan_id',
'siswa_id'
];
public function siswa(){
return $this->hasOne('App\Models\Siswa','id','siswa_id');
}
public function tagihan(){
return $this->hasOne('App\Models\Tagihan','id','tagihan_id');
}
}

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Siswa extends Model
{
use SoftDeletes;
protected $table = 'siswa';
protected $fillable = [
'kelas_id',
'nama',
'tempat_lahir',
'tanggal_lahir',
'jenis_kelamin',
'alamat',
'nama_wali',
'telp_wali',
'pekerjaan_wali',
'is_yatim'
];
public function kelas(){
return $this->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');
}
}

@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Tabungan extends Model
{
use SoftDeletes;
protected $table = 'tabungan';
protected $fillable = [
'siswa_id',
'tipe',
'jumlah',
'saldo',
'keperluan'
];
public function siswa(){
return $this->belongsTo('App\Models\Siswa','id','siswa_id');
}
public function keuangan(){
return $this->hasOne('App\Models\Keuangan','tabungan_id','id');
}
}

@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Tagihan extends Model
{
use SoftDeletes;
protected $table = 'tagihan';
protected $fillable = [
'nama',
'jumlah',
'wajib_semua',
'hanya_kelas'
];
public function transaksi(){
return $this->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');
}
}

@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Transaksi extends Model
{
use SoftDeletes;
protected $table = 'transaksi';
protected $fillable = [
'siswa_id',
'tagihan_id',
'total',
'diskon',
'is_lunas',
'keterangan'
];
public function tagihan(){
return $this->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');
}
}

@ -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();

@ -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();
});

@ -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();
});

@ -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();
});

@ -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();
});

@ -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();
});

Loading…
Cancel
Save