-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fcfccc
commit dedcb94
Showing
8 changed files
with
277 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Models\Expense; | ||
|
||
use App\Models\Model; | ||
use App\Traits\Currencies; | ||
|
||
class BillItemTax extends Model | ||
{ | ||
|
||
use Currencies; | ||
|
||
protected $table = 'bill_item_taxes'; | ||
|
||
/** | ||
* Attributes that should be mass-assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = ['company_id', 'bill_id', 'bill_item_id', 'tax_id', 'name', 'amount']; | ||
|
||
public function bill() | ||
{ | ||
return $this->belongsTo('App\Models\Expense\Bill'); | ||
} | ||
|
||
public function item() | ||
{ | ||
return $this->belongsTo('App\Models\Common\Item'); | ||
} | ||
|
||
public function tax() | ||
{ | ||
return $this->belongsTo('App\Models\Setting\Tax'); | ||
} | ||
|
||
/** | ||
* Convert amount to double. | ||
* | ||
* @param string $value | ||
* @return void | ||
*/ | ||
public function setAmountAttribute($value) | ||
{ | ||
$this->attributes['amount'] = (double) $value; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
database/migrations/2018_10_22_000000_create_bill_item_taxes_table.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateBillItemTaxesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('bill_item_taxes', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->integer('company_id'); | ||
$table->integer('bill_id'); | ||
$table->integer('bill_item_id'); | ||
$table->integer('tax_id'); | ||
$table->string('name'); | ||
$table->double('amount', 15, 4)->default('0.0000'); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
|
||
$table->index('company_id'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('bill_item_taxes'); | ||
} | ||
} |
Oops, something went wrong.