$pinjam = Pinjam::first();
$barang = $pinjam->barang;
$kondisi = $barang->kondisi->field_yang_akan_diambil;
// atau
$kondisi = $pinjam->barang->kondisi->field_yang_akan_diambil;
Last active
August 29, 2015 14:21
-
-
Save gravitano/fc8b2f2a43b8b080de99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Barang extends Model { | |
protected $primaryKey = 'id_barang'; | |
public function kondisi() | |
{ | |
return $this->belongsTo('App\Kondisi', 'id_kondisi', 'kondisi_id'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Kondisi extends Model { | |
protected $primaryKey = 'kondisi_id'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Pinjam extends Model { | |
protected $primaryKey = 'id'; | |
public function barang() | |
{ | |
return $this->belongsTo('App\Barang', 'lbl_brg', 'id_barang'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment