Tweaks
This commit is contained in:
parent
3f6de174e5
commit
e6ce2f5928
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Adjustment\DataTables;
|
||||
|
||||
use Modules\Adjustment\Entities\Adjustment;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -20,8 +20,13 @@ class Adjustment extends Model
|
|||
return $this->hasMany(AdjustedProduct::class, 'adjustment_id', 'id');
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT );
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$number = Adjustment::max('id') + 1;
|
||||
$model->reference = make_reference_id('ADJ', $number);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Adjustment\Http\Controllers;
|
||||
|
||||
use App\DataTables\AdjustmentsDataTable;
|
||||
use Modules\Adjustment\DataTables\AdjustmentsDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Gate;
|
|||
use Modules\Adjustment\Entities\AdjustedProduct;
|
||||
use Modules\Adjustment\Entities\Adjustment;
|
||||
use Modules\Product\Entities\Product;
|
||||
use Modules\Product\Notifications\NotifyQuantityAlert;
|
||||
|
||||
class AdjustmentController extends Controller
|
||||
{
|
||||
|
@ -43,9 +44,8 @@ class AdjustmentController extends Controller
|
|||
|
||||
DB::transaction(function () use ($request) {
|
||||
$adjustment = Adjustment::create([
|
||||
'reference' => $request->reference,
|
||||
'date' => $request->date,
|
||||
'note' => $request->note
|
||||
'date' => $request->date,
|
||||
'note' => $request->note
|
||||
]);
|
||||
|
||||
foreach ($request->product_ids as $key => $id) {
|
||||
|
@ -128,15 +128,14 @@ class AdjustmentController extends Controller
|
|||
foreach ($request->product_ids as $key => $id) {
|
||||
AdjustedProduct::create([
|
||||
'adjustment_id' => $adjustment->id,
|
||||
'product_id' => $id,
|
||||
'product_id' => $id,
|
||||
'quantity' => $request->quantities[$key],
|
||||
'type' => $request->types[$key]
|
||||
]);
|
||||
|
||||
$product = Product::findOrFail($id);
|
||||
|
||||
if ($request->types[$key] == 'add')
|
||||
{
|
||||
if ($request->types[$key] == 'add') {
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity + $request->quantities[$key]
|
||||
]);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Currency\DataTables;
|
||||
|
||||
use Modules\Currency\Entities\Currency;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Modules\Currency\Http\Controllers;
|
||||
|
||||
use App\DataTables\CurrencyDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Modules\Currency\DataTables\CurrencyDataTable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Expense\DataTables;
|
||||
|
||||
use Modules\Expense\Entities\ExpenseCategory;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Expense\DataTables;
|
||||
|
||||
use Modules\Expense\Entities\Expense;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -16,6 +16,15 @@ class Expense extends Model
|
|||
return $this->belongsTo(ExpenseCategory::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$number = Expense::max('id') + 1;
|
||||
$model->reference = make_reference_id('EXP', $number);
|
||||
});
|
||||
}
|
||||
|
||||
public function getDateAttribute($value) {
|
||||
return Carbon::parse($value)->format('d M, Y');
|
||||
}
|
||||
|
@ -27,8 +36,4 @@ class Expense extends Model
|
|||
public function getAmountAttribute($value) {
|
||||
return ($value / 100);
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Expense\Http\Controllers;
|
||||
|
||||
use App\DataTables\ExpenseCategoriesDataTable;
|
||||
use Modules\Expense\DataTables\ExpenseCategoriesDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Expense\Http\Controllers;
|
||||
|
||||
use App\DataTables\ExpensesDataTable;
|
||||
use Modules\Expense\DataTables\ExpensesDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
@ -40,7 +40,6 @@ class ExpenseController extends Controller
|
|||
|
||||
Expense::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'category_id' => $request->category_id,
|
||||
'amount' => $request->amount,
|
||||
'details' => $request->details
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required value="{{ $expense->getAttributes()['reference'] }}" readonly>
|
||||
<input type="text" class="form-control" name="reference" required value="{{ $expense->reference }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\People\DataTables;
|
||||
|
||||
|
||||
use Modules\People\Entities\Customer;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\People\DataTables;
|
||||
|
||||
|
||||
use Modules\People\Entities\Supplier;
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\People\Http\Controllers;
|
||||
|
||||
use App\DataTables\CustomersDataTable;
|
||||
use Modules\People\DataTables\CustomersDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\People\Http\Controllers;
|
||||
|
||||
use App\DataTables\SuppliersDataTable;
|
||||
use Modules\People\DataTables\SuppliersDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Product\DataTables;
|
||||
|
||||
use Modules\Product\Entities\Category;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Product\DataTables;
|
||||
|
||||
use Modules\Product\Entities\Product;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -4,6 +4,7 @@ namespace Modules\Product\Entities;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Product\Notifications\NotifyQuantityAlert;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
|
|
@ -7,7 +7,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Modules\Product\Entities\Category;
|
||||
use App\DataTables\ProductCategoriesDataTable;
|
||||
use Modules\Product\DataTables\ProductCategoriesDataTable;
|
||||
|
||||
class CategoriesController extends Controller
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Product\Http\Controllers;
|
||||
|
||||
use App\DataTables\ProductDataTable;
|
||||
use Modules\Product\DataTables\ProductDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Purchase\DataTables;
|
||||
|
||||
use Modules\Purchase\Entities\Purchase;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Purchase\DataTables;
|
||||
|
||||
use Modules\Purchase\Entities\PurchasePayment;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -19,8 +19,13 @@ class Purchase extends Model
|
|||
return $this->hasMany(PurchasePayment::class, 'purchase_id', 'id');
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT);
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$number = Purchase::max('id') + 1;
|
||||
$model->reference = make_reference_id('PR', $number);
|
||||
});
|
||||
}
|
||||
|
||||
public function getShippingAmountAttribute($value) {
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Modules\Purchase\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchaseDataTable;
|
||||
use Modules\Purchase\DataTables\PurchaseDataTable;
|
||||
use Gloudemans\Shoppingcart\Facades\Cart;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
@ -49,7 +47,6 @@ class PurchaseController extends Controller
|
|||
|
||||
$purchase = Purchase::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'supplier_id' => $request->supplier_id,
|
||||
'supplier_name' => Supplier::findOrFail($request->supplier_id)->supplier_name,
|
||||
'tax_percentage' => $request->tax_percentage,
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Modules\Purchase\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchasePaymentsDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Modules\Purchase\DataTables\PurchasePaymentsDataTable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required value="PR" readonly>
|
||||
<input type="text" class="form-control" name="reference" required value="{{ $purchase->reference }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\PurchasesReturn\DataTables;
|
||||
|
||||
use Modules\PurchasesReturn\Entities\PurchaseReturnPayment;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\PurchasesReturn\DataTables;
|
||||
|
||||
use Modules\PurchasesReturn\Entities\PurchaseReturn;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -19,8 +19,13 @@ class PurchaseReturn extends Model
|
|||
return $this->hasMany(PurchaseReturnPayment::class, 'purchase_return_id', 'id');
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT);
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$number = PurchaseReturn::max('id') + 1;
|
||||
$model->reference = make_reference_id('PRRN', $number);
|
||||
});
|
||||
}
|
||||
|
||||
public function getShippingAmountAttribute($value) {
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Modules\PurchasesReturn\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchaseReturnPaymentsDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Modules\PurchasesReturn\DataTables\PurchaseReturnPaymentsDataTable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Modules\PurchasesReturn\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchaseReturnsDataTable;
|
||||
use Modules\PurchasesReturn\DataTables\PurchaseReturnsDataTable;
|
||||
use Gloudemans\Shoppingcart\Facades\Cart;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
@ -50,7 +48,6 @@ class PurchasesReturnController extends Controller
|
|||
|
||||
$purchase_return = PurchaseReturn::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'supplier_id' => $request->supplier_id,
|
||||
'supplier_name' => Supplier::findOrFail($request->supplier_id)->supplier_name,
|
||||
'tax_percentage' => $request->tax_percentage,
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required value="PRRN" readonly>
|
||||
<input type="text" class="form-control" name="reference" required value="{{ $purchase_return->reference }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Sale\DataTables;
|
||||
|
||||
use Modules\Sale\Entities\SalePayment;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\Sale\DataTables;
|
||||
|
||||
use Modules\Sale\Entities\Sale;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -19,8 +19,13 @@ class Sale extends Model
|
|||
return $this->hasMany(SalePayment::class, 'sale_id', 'id');
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT);
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$number = Sale::max('id') + 1;
|
||||
$model->reference = make_reference_id('SL', $number);
|
||||
});
|
||||
}
|
||||
|
||||
public function getShippingAmountAttribute($value) {
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Modules\Sale\Http\Controllers;
|
||||
|
||||
use App\DataTables\SalesDataTable;
|
||||
use Modules\Sale\DataTables\SalesDataTable;
|
||||
use Gloudemans\Shoppingcart\Facades\Cart;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
@ -50,7 +48,6 @@ class SaleController extends Controller
|
|||
|
||||
$sale = Sale::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'customer_id' => $request->customer_id,
|
||||
'customer_name' => Customer::findOrFail($request->customer_id)->customer_name,
|
||||
'tax_percentage' => $request->tax_percentage,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Sale\Http\Controllers;
|
||||
|
||||
use App\DataTables\SalePaymentsDataTable;
|
||||
use Modules\Sale\DataTables\SalePaymentsDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required value="SL" readonly>
|
||||
<input type="text" class="form-control" name="reference" required value="{{ $sale->reference }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\SalesReturn\DataTables;
|
||||
|
||||
use Modules\SalesReturn\Entities\SaleReturnPayment;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\SalesReturn\DataTables;
|
||||
|
||||
use Modules\SalesReturn\Entities\SaleReturn;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -19,8 +19,13 @@ class SaleReturn extends Model
|
|||
return $this->hasMany(SaleReturnPayment::class, 'sale_return_id', 'id');
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT);
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$number = SaleReturn::max('id') + 1;
|
||||
$model->reference = make_reference_id('SLRN', $number);;
|
||||
});
|
||||
}
|
||||
|
||||
public function getShippingAmountAttribute($value) {
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Modules\SalesReturn\Http\Controllers;
|
||||
|
||||
use App\DataTables\SaleReturnPaymentsDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Modules\SalesReturn\DataTables\SaleReturnPaymentsDataTable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Modules\SalesReturn\Http\Controllers;
|
||||
|
||||
use App\DataTables\SaleReturnsDataTable;
|
||||
use Modules\SalesReturn\DataTables\SaleReturnsDataTable;
|
||||
use Gloudemans\Shoppingcart\Facades\Cart;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
@ -50,7 +48,6 @@ class SalesReturnController extends Controller
|
|||
|
||||
$sale_return = SaleReturn::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'customer_id' => $request->customer_id,
|
||||
'customer_name' => Customer::findOrFail($request->customer_id)->customer_name,
|
||||
'tax_percentage' => $request->tax_percentage,
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required value="SLRN" readonly>
|
||||
<input type="text" class="form-control" name="reference" required value="{{ $sale_return->reference }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\User\DataTables;
|
||||
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
namespace Modules\User\DataTables;
|
||||
|
||||
use App\Models\User;
|
||||
use Yajra\DataTables\Html\Button;
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use App\DataTables\RolesDataTable;
|
||||
use Modules\User\DataTables\RolesDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use App\DataTables\UsersDataTable;
|
||||
use Modules\User\DataTables\UsersDataTable;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="password_confirmation">Password <span
|
||||
<label for="password_confirmation">Confirm Password <span
|
||||
class="text-danger">*</span></label>
|
||||
<input class="form-control" type="password" name="password_confirmation"
|
||||
required>
|
||||
|
|
|
@ -12,8 +12,10 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
Route::get('/user/profile', 'ProfileController@edit')->name('profile.edit');
|
||||
Route::patch('/user/profile', 'ProfileController@update')->name('profile.update');
|
||||
Route::patch('/user/password', 'ProfileController@updatePassword')->name('profile.update.password');
|
||||
|
||||
//Users
|
||||
Route::resource('users', 'UsersController')->except('show');
|
||||
|
||||
//Roles
|
||||
Route::resource('roles', 'RolesController')->except('show');
|
||||
|
||||
|
|
|
@ -32,6 +32,14 @@ if (!function_exists('format_currency')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!function_exists('make_reference_id')) {
|
||||
function make_reference_id($prefix, $number) {
|
||||
$padded_text = $prefix . '-' . str_pad($number, 5, 0, STR_PAD_LEFT);
|
||||
|
||||
return $padded_text;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('array_merge_numeric_values')) {
|
||||
function array_merge_numeric_values() {
|
||||
$arrays = func_get_args();
|
||||
|
|
|
@ -10,11 +10,13 @@ class SearchProduct extends Component
|
|||
{
|
||||
|
||||
public $query;
|
||||
public $searchResults;
|
||||
public $search_results;
|
||||
public $how_many;
|
||||
|
||||
public function mount() {
|
||||
$this->query = '';
|
||||
$this->searchResults = Collection::empty();
|
||||
$this->how_many = 5;
|
||||
$this->search_results = Collection::empty();
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
@ -22,14 +24,20 @@ class SearchProduct extends Component
|
|||
}
|
||||
|
||||
public function updatedQuery() {
|
||||
$this->searchResults = Product::where('product_name', 'like', '%' . $this->query . '%')
|
||||
$this->search_results = Product::where('product_name', 'like', '%' . $this->query . '%')
|
||||
->orWhere('product_code', 'like', '%' . $this->query . '%')
|
||||
->take(6)->get();
|
||||
->take($this->how_many)->get();
|
||||
}
|
||||
|
||||
public function loadMore() {
|
||||
$this->how_many += 5;
|
||||
$this->updatedQuery();
|
||||
}
|
||||
|
||||
public function resetQuery() {
|
||||
$this->query = '';
|
||||
$this->searchResults = Collection::empty();
|
||||
$this->how_many = 5;
|
||||
$this->search_results = Collection::empty();
|
||||
}
|
||||
|
||||
public function selectProduct($product) {
|
||||
|
|
|
@ -6,6 +6,8 @@ use Illuminate\Auth\Events\Registered;
|
|||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Modules\Product\Entities\Product;
|
||||
use Modules\Product\Observers\ProductObserver;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateNotificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
}
|
|
@ -19,13 +19,26 @@
|
|||
<li class="c-header-nav-item dropdown d-md-down-none mr-2">
|
||||
<a class="c-header-nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bi bi-bell" style="font-size: 20px;"></i>
|
||||
<span class="badge badge-pill badge-danger">0</span>
|
||||
<span class="badge badge-pill badge-danger">
|
||||
@php
|
||||
$low_quantity_products = \Modules\Product\Entities\Product::select('id', 'product_quantity', 'product_stock_alert', 'product_code')->whereColumn('product_quantity', '<=', 'product_stock_alert')->get();
|
||||
echo $low_quantity_products->count();
|
||||
@endphp
|
||||
</span>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-lg pt-0">
|
||||
<div class="dropdown-header bg-light"><strong>You have 0 notification.</strong></div>
|
||||
<a class="dropdown-item" href="#">
|
||||
<i class="bi bi-app-indicator mr-2 text-danger"></i> No notification available.
|
||||
</a>
|
||||
<div class="dropdown-header bg-light">
|
||||
<strong>{{ $low_quantity_products->count() }} Notifications</strong>
|
||||
</div>
|
||||
@forelse($low_quantity_products as $product)
|
||||
<a class="dropdown-item" href="{{ route('products.show', $product->id) }}">
|
||||
<i class="bi bi-hash mr-1 text-primary"></i> Product: "{{ $product->product_code }}" is low in qauntity!
|
||||
</a>
|
||||
@empty
|
||||
<a class="dropdown-item" href="#">
|
||||
<i class="bi bi-app-indicator mr-2 text-danger"></i> No notifications available.
|
||||
</a>
|
||||
@endforelse
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">
|
||||
<i class="bi bi-search"></i>
|
||||
<i class="bi bi-search text-primary"></i>
|
||||
</div>
|
||||
</div>
|
||||
<input wire:keydown.escape="resetQuery" wire:model.debounce.500ms="query" type="text" class="form-control" placeholder="Type product name or code....">
|
||||
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div wire:loading wire:target="query" class="card position-absolute mt-1 border-0" style="z-index: 1;left: 0;right: 0;">
|
||||
<div wire:loading class="card position-absolute mt-1 border-0" style="z-index: 1;left: 0;right: 0;">
|
||||
<div class="card-body shadow">
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
|
@ -26,17 +26,24 @@
|
|||
|
||||
@if(!empty($query))
|
||||
<div wire:click="resetQuery" class="position-fixed w-100 h-100" style="left: 0; top: 0; right: 0; bottom: 0;z-index: 1;"></div>
|
||||
@if($searchResults->isNotEmpty())
|
||||
@if($search_results->isNotEmpty())
|
||||
<div class="card position-absolute mt-1" style="z-index: 2;left: 0;right: 0;border: 0;">
|
||||
<div class="card-body shadow">
|
||||
<ul class="list-group list-group-flush">
|
||||
@foreach($searchResults as $result)
|
||||
@foreach($search_results as $result)
|
||||
<li class="list-group-item list-group-item-action">
|
||||
<a wire:click="resetQuery" wire:click.prevent="selectProduct({{ $result }})" href="#">
|
||||
{{ $result->product_name }} | {{ $result->product_code }}
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
@if($search_results->count() >= $how_many)
|
||||
<li class="list-group-item list-group-item-action text-center">
|
||||
<a wire:click.prevent="loadMore" class="btn btn-primary btn-sm" href="#">
|
||||
Load More <i class="bi bi-arrow-down-circle"></i>
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue