ronaldkwandy

Untitled

Oct 21st, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Masters\Merk;
  4.  
  5. use Illuminate\Database\Eloquent\Model;
  6. use Auth;
  7.  
  8. /**
  9.  * App\Http\Controllers\Masters\Merk
  10.  *
  11.  * @property integer $id
  12.  */
  13. class Merk extends Model {
  14.  
  15.     public static $singleKey = "merk";
  16.     public static $multiKey = "merks";
  17.     public static $searchParams = ["nama", "aktif"];
  18.     protected $table = 'm_merk';
  19.     protected $fillable = ['nama', 'aktif'];
  20.  
  21.     protected static function boot() {
  22.         parent::boot();
  23.  
  24.         static::creating(function ($model) {
  25.             $model->created_by = Auth::check() ? Auth::user()->nama : 'Ryner';
  26.             $model->updated_by = Auth::check() ? Auth::user()->nama : 'Ryner';
  27.         });
  28.  
  29.         static::updating(function ($model) {
  30.             $model->updated_by = Auth::check() ? Auth::user()->nama : 'Ryner';
  31.         });
  32.     }
  33.  
  34.     public function barang() {
  35.         return $this->hasMany('App\Http\Controllers\Masters\Barang\Barang');
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment