IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Book.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;


class Book extends Model {

    protected $primaryKey = 'idBook';
    protected $table = 'books';
    protected $fillable = ['idBookType','accessionNo','entryDate','idPublisher','rfid','idPlace','title','publicationYear',
        'subtitle','idAuthor','idLanguage','classificationNo','idSourceLanguage','idClassification','idBookLocation','idSubClassno',
        'idSubClasstwo','idEditor','idBookSeries','volumnNo','isbnNo','issnNo','edition','idVendor','idBookSubject','idFaculty'
        ,'idBindingType','idBookSize','idMaterial','idCorporate','billNo','billDate','purchaseDate','originalCost','discount'
        ,'costAfterDiscount','bookImage','keywords','notes','ebook','noOfPages','noOfCopy'];

    
    public function setEntryDateAttribute($date) {
        if (strlen($date) > 0)
            $this->attributes['entryDate'] = Carbon::createFromFormat('d-m-Y', $date);
        else
            $this->attributes['entryDate'] = null;
    }

    public function getEntryDateAttribute($date) {
        if ($date && $date != '0000-00-00' && $date != 'null')
            return Carbon::parse($date)->format('d-m-Y');
        return '';
    }
    
    public function setBillDateAttribute($date) {
        if (strlen($date) > 0)
            $this->attributes['billDate'] = Carbon::createFromFormat('d-m-Y', $date);
        else
            $this->attributes['billDate'] = null;
    }

    public function getBillDateAttribute($date) {
        if ($date && $date != '0000-00-00' && $date != 'null')
            return Carbon::parse($date)->format('d-m-Y');
        return '';
    }
    
    public function setPurchaseDateAttribute($date) {
        if (strlen($date) > 0)
            $this->attributes['purchaseDate'] = Carbon::createFromFormat('d-m-Y', $date);
        else
            $this->attributes['purchaseDate'] = null;
    }

    public function getPurchaseDateAttribute($date) {
        if ($date && $date != '0000-00-00' && $date != 'null')
            return Carbon::parse($date)->format('d-m-Y');
        return '';
    }
    
    public function boookType() {
        return $this->belongsTo(BookType::class,'idBookType','idBookType');
    }

}

Copyright © 2021 - 2025 IMMREX7