mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for language seeder
This commit is contained in:
parent
37b2fac69d
commit
375ce81df9
@ -105,7 +105,7 @@ class Expense extends BaseModel
|
||||
|
||||
public function purchase_order()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class);
|
||||
return $this->hasOne(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
|
@ -169,7 +169,7 @@ class PurchaseOrder extends BaseModel
|
||||
|
||||
public function expense()
|
||||
{
|
||||
return $this->hasOne(Expense::class);
|
||||
return $this->belongsTo(Expense::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
|
@ -94,7 +94,6 @@ class ExpenseTransformer extends EntityTransformer
|
||||
'uses_inclusive_taxes' => (bool) $expense->uses_inclusive_taxes,
|
||||
'calculate_tax_by_amount' => (bool) $expense->calculate_tax_by_amount,
|
||||
'entity_type' => 'expense',
|
||||
'purchase_order_id' => (string) $this->encodePrimaryKey($expense->purchase_order_id),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,10 @@ class PurchaseOrderTransformer extends EntityTransformer
|
||||
'documents'
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'expense'
|
||||
];
|
||||
|
||||
public function includeInvitations(PurchaseOrder $purchase_order)
|
||||
{
|
||||
$transformer = new PurchaseOrderInvitationTransformer($this->serializer);
|
||||
@ -41,6 +45,13 @@ class PurchaseOrderTransformer extends EntityTransformer
|
||||
return $this->includeCollection($purchase_order->documents, $transformer, Document::class);
|
||||
}
|
||||
|
||||
public function includeExpense(PurchaseOrder $purchase_order)
|
||||
{
|
||||
$transformer = new ExpenseTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($purchase_order->expense, $transformer, Document::class);
|
||||
}
|
||||
|
||||
public function transform(PurchaseOrder $purchase_order)
|
||||
{
|
||||
return [
|
||||
@ -103,6 +114,7 @@ class PurchaseOrderTransformer extends EntityTransformer
|
||||
'exchange_rate' => (float)$purchase_order->exchange_rate,
|
||||
'paid_to_date' => (float)$purchase_order->paid_to_date,
|
||||
'subscription_id' => $this->encodePrimaryKey($purchase_order->subscription_id),
|
||||
'expense_id' => $this->encodePrimaryKey($purchase_order->expense_id),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -25,27 +25,23 @@ class AddPurchaseOrderToExpense extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('expenses', function (Blueprint $table) {
|
||||
$table->unsignedInteger('purchase_order_id')->nullable()->index();
|
||||
Schema::table('purchase_orders', function (Blueprint $table) {
|
||||
$table->unsignedInteger('expense_id')->nullable()->index();
|
||||
});
|
||||
|
||||
PurchaseOrder::withTrashed()->where('status_id', 4)->update(['status_id' => 5]);
|
||||
|
||||
|
||||
$language = Language::find(33);
|
||||
$language = Language::where('locale', 'bg')->first();
|
||||
|
||||
if(!$language)
|
||||
{
|
||||
Language::unguard();
|
||||
|
||||
$l = new Language();
|
||||
$l->id = 33;
|
||||
$l->name = "Bulgarian";
|
||||
$l->locale = "bg";
|
||||
$l->save();
|
||||
|
||||
Language::reguard();
|
||||
|
||||
$this->buildCache(true);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ class LanguageSeeder extends Seeder
|
||||
['id' => 30, 'name' => 'Arabic', 'locale' => 'ar'],
|
||||
['id' => 31, 'name' => 'Persian', 'locale' => 'fa'],
|
||||
['id' => 32, 'name' => 'Latvian', 'locale' => 'lv_LV'],
|
||||
['id' => 33, 'name' => 'Bulgarian', 'locale' => 'bg'],
|
||||
];
|
||||
|
||||
foreach ($languages as $language) {
|
||||
|
Loading…
Reference in New Issue
Block a user