Added: Currency Module
This commit is contained in:
parent
bbdfa70b1f
commit
08c1818a9d
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => 'Currency'
|
||||||
|
];
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateCurrenciesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('currencies', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('currency_name');
|
||||||
|
$table->string('code');
|
||||||
|
$table->string('symbol');
|
||||||
|
$table->string('thousand_separator');
|
||||||
|
$table->string('decimal_separator');
|
||||||
|
$table->integer('exchange_rate')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('currencies');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Currency\Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CurrencyDatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
Model::unguard();
|
||||||
|
|
||||||
|
// $this->call("OthersTableSeeder");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Currency\Entities;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
|
class Currency extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Currency\Http\Controllers;
|
||||||
|
|
||||||
|
use App\DataTables\CurrencyDataTable;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Modules\Currency\Entities\Currency;
|
||||||
|
|
||||||
|
class CurrencyController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(CurrencyDataTable $dataTable) {
|
||||||
|
abort_if(Gate::denies('access_currencies'), 403);
|
||||||
|
|
||||||
|
return $dataTable->render('currency::index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function create() {
|
||||||
|
abort_if(Gate::denies('create_currencies'), 403);
|
||||||
|
|
||||||
|
return view('currency::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request) {
|
||||||
|
abort_if(Gate::denies('create_currencies'), 403);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'currency_name' => 'required|string|max:255',
|
||||||
|
'code' => 'required|string|max:255',
|
||||||
|
'symbol' => 'required|string|max:255',
|
||||||
|
'thousand_separator' => 'required|string|max:255',
|
||||||
|
'decimal_separator' => 'required|string|max:255',
|
||||||
|
'exchange_rate' => 'nullable|numeric|max:2147483647'
|
||||||
|
]);
|
||||||
|
|
||||||
|
Currency::create([
|
||||||
|
'currency_name' => $request->currency_name,
|
||||||
|
'code' => Str::upper($request->code),
|
||||||
|
'symbol' => $request->symbol,
|
||||||
|
'thousand_separator' => $request->thousand_separator,
|
||||||
|
'decimal_separator' => $request->decimal_separator,
|
||||||
|
'exchange_rate' => $request->exchange_rate
|
||||||
|
]);
|
||||||
|
|
||||||
|
toast('Currency Created!', 'success');
|
||||||
|
|
||||||
|
return redirect()->route('currencies.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit(Currency $currency) {
|
||||||
|
abort_if(Gate::denies('edit_currencies'), 403);
|
||||||
|
|
||||||
|
return view('currency::edit', compact('currency'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, Currency $currency) {
|
||||||
|
abort_if(Gate::denies('edit_currencies'), 403);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'currency_name' => 'required|string|max:255',
|
||||||
|
'code' => 'required|string|max:255',
|
||||||
|
'symbol' => 'required|string|max:255',
|
||||||
|
'thousand_separator' => 'required|string|max:255',
|
||||||
|
'decimal_separator' => 'required|string|max:255',
|
||||||
|
'exchange_rate' => 'nullable|numeric|max:2147483647'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$currency->update([
|
||||||
|
'currency_name' => $request->currency_name,
|
||||||
|
'code' => Str::upper($request->code),
|
||||||
|
'symbol' => $request->symbol,
|
||||||
|
'thousand_separator' => $request->thousand_separator,
|
||||||
|
'decimal_separator' => $request->decimal_separator,
|
||||||
|
'exchange_rate' => $request->exchange_rate
|
||||||
|
]);
|
||||||
|
|
||||||
|
toast('Currency Updated!', 'info');
|
||||||
|
|
||||||
|
return redirect()->route('currencies.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy(Currency $currency) {
|
||||||
|
abort_if(Gate::denies('delete_currencies'), 403);
|
||||||
|
|
||||||
|
$currency->delete();
|
||||||
|
|
||||||
|
toast('Currency Deleted!', 'warning');
|
||||||
|
|
||||||
|
return redirect()->route('currencies.index');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Currency\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Database\Eloquent\Factory;
|
||||||
|
|
||||||
|
class CurrencyServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string $moduleName
|
||||||
|
*/
|
||||||
|
protected $moduleName = 'Currency';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string $moduleNameLower
|
||||||
|
*/
|
||||||
|
protected $moduleNameLower = 'currency';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerTranslations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerViews();
|
||||||
|
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->app->register(RouteServiceProvider::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register config.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerConfig()
|
||||||
|
{
|
||||||
|
$this->publishes([
|
||||||
|
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||||
|
], 'config');
|
||||||
|
$this->mergeConfigFrom(
|
||||||
|
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register views.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerViews()
|
||||||
|
{
|
||||||
|
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||||
|
|
||||||
|
$sourcePath = module_path($this->moduleName, 'Resources/views');
|
||||||
|
|
||||||
|
$this->publishes([
|
||||||
|
$sourcePath => $viewPath
|
||||||
|
], ['views', $this->moduleNameLower . '-module-views']);
|
||||||
|
|
||||||
|
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register translations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerTranslations()
|
||||||
|
{
|
||||||
|
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||||
|
|
||||||
|
if (is_dir($langPath)) {
|
||||||
|
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||||
|
} else {
|
||||||
|
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPublishableViewPaths(): array
|
||||||
|
{
|
||||||
|
$paths = [];
|
||||||
|
foreach (\Config::get('view.paths') as $path) {
|
||||||
|
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||||
|
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $paths;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Currency\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The module namespace to assume when generating URLs to actions.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $moduleNamespace = 'Modules\Currency\Http\Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before routes are registered.
|
||||||
|
*
|
||||||
|
* Register any model bindings or pattern based filters.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the routes for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function map()
|
||||||
|
{
|
||||||
|
$this->mapApiRoutes();
|
||||||
|
|
||||||
|
$this->mapWebRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the "web" routes for the application.
|
||||||
|
*
|
||||||
|
* These routes all receive session state, CSRF protection, etc.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function mapWebRoutes()
|
||||||
|
{
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->moduleNamespace)
|
||||||
|
->group(module_path('Currency', '/Routes/web.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the "api" routes for the application.
|
||||||
|
*
|
||||||
|
* These routes are typically stateless.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function mapApiRoutes()
|
||||||
|
{
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->moduleNamespace)
|
||||||
|
->group(module_path('Currency', '/Routes/api.php'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Create Currency')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<ol class="breadcrumb border-0 m-0">
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('currencies.index') }}">Currencies</a></li>
|
||||||
|
<li class="breadcrumb-item active">Add</li>
|
||||||
|
</ol>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-fluid">
|
||||||
|
<form action="{{ route('currencies.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
@include('utils.alerts')
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-primary">Create Currency <i class="bi bi-check"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="currency_name">Currency Name <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="currency_name" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="code">Currency Code <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="code" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="symbol">Symbol <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="symbol" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="thousand_separator">Thousand Separator <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="thousand_separator" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="decimal_separator">Decimal Separator <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="decimal_separator" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Create Customer')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<ol class="breadcrumb border-0 m-0">
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('currencies.index') }}">Currencies</a></li>
|
||||||
|
<li class="breadcrumb-item active">Edit</li>
|
||||||
|
</ol>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-fluid">
|
||||||
|
<form action="{{ route('currencies.update', $currency) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('patch')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
@include('utils.alerts')
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-primary">Update Currency <i class="bi bi-check"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="currency_name">Currency Name <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="currency_name" required value="{{ $currency->currency_name }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="code">Currency Code <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="code" required value="{{ $currency->code }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="symbol">Symbol <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="symbol" required value="{{ $currency->symbol }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="thousand_separator">Thousand Separator <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="thousand_separator" required value="{{ $currency->thousand_separator }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="decimal_separator">Decimal Separator <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="decimal_separator" required value="{{ $currency->decimal_separator }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Currencies')
|
||||||
|
|
||||||
|
@section('third_party_stylesheets')
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<ol class="breadcrumb border-0 m-0">
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||||
|
<li class="breadcrumb-item active">Currencies</li>
|
||||||
|
</ol>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<a href="{{ route('currencies.create') }}" class="btn btn-primary">
|
||||||
|
Add Currency <i class="bi bi-plus"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
{!! $dataTable->table() !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
{!! $dataTable->scripts() !!}
|
||||||
|
@endpush
|
|
@ -0,0 +1,19 @@
|
||||||
|
@can('edit_currencies')
|
||||||
|
<a href="{{ route('currencies.edit', $data->id) }}" class="btn btn-info btn-sm">
|
||||||
|
<i class="bi bi-pencil"></i>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@can('delete_currencies')
|
||||||
|
<button id="delete" class="btn btn-danger btn-sm" onclick="
|
||||||
|
event.preventDefault();
|
||||||
|
if (confirm('Are you sure? It will delete the data permanently!')) {
|
||||||
|
document.getElementById('destroy{{ $data->id }}').submit()
|
||||||
|
}
|
||||||
|
">
|
||||||
|
<i class="bi bi-trash"></i>
|
||||||
|
<form id="destroy{{ $data->id }}" class="d-none" action="{{ route('currencies.destroy', $data->id) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('delete')
|
||||||
|
</form>
|
||||||
|
</button>
|
||||||
|
@endcan
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| API Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register API routes for your application. These
|
||||||
|
| routes are loaded by the RouteServiceProvider within a group which
|
||||||
|
| is assigned the "api" middleware group. Enjoy building your API!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
Route::middleware('auth:api')->get('/currency', function (Request $request) {
|
||||||
|
return $request->user();
|
||||||
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Web Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register web routes for your application. These
|
||||||
|
| routes are loaded by the RouteServiceProvider within a group which
|
||||||
|
| contains the "web" middleware group. Now create something great!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
Route::group(['middleware' => 'auth'], function () {
|
||||||
|
|
||||||
|
Route::resource('currencies', 'CurrencyController')->except('show');
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"name": "nwidart/currency",
|
||||||
|
"description": "",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Widart",
|
||||||
|
"email": "n.widart@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [],
|
||||||
|
"aliases": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Modules\\Currency\\": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "Currency",
|
||||||
|
"alias": "currency",
|
||||||
|
"description": "",
|
||||||
|
"keywords": [],
|
||||||
|
"priority": 0,
|
||||||
|
"providers": [
|
||||||
|
"Modules\\Currency\\Providers\\CurrencyServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {},
|
||||||
|
"files": [],
|
||||||
|
"requires": []
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "npm run development",
|
||||||
|
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch-poll": "npm run watch -- --watch-poll",
|
||||||
|
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"prod": "npm run production",
|
||||||
|
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"cross-env": "^7.0",
|
||||||
|
"laravel-mix": "^5.0.1",
|
||||||
|
"laravel-mix-merge-manifest": "^0.1.2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
const dotenvExpand = require('dotenv-expand');
|
||||||
|
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
|
||||||
|
|
||||||
|
const mix = require('laravel-mix');
|
||||||
|
require('laravel-mix-merge-manifest');
|
||||||
|
|
||||||
|
mix.setPublicPath('../../public').mergeManifest();
|
||||||
|
|
||||||
|
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/currency.js')
|
||||||
|
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/currency.css');
|
||||||
|
|
||||||
|
if (mix.inProduction()) {
|
||||||
|
mix.version();
|
||||||
|
}
|
|
@ -19,4 +19,12 @@ class Expense extends Model
|
||||||
public function getDateAttribute($value) {
|
public function getDateAttribute($value) {
|
||||||
return Carbon::parse($value)->format('d M, Y');
|
return Carbon::parse($value)->format('d M, Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setAmountAttribute($value) {
|
||||||
|
$this->attributes['amount'] = ($value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAmountAttribute($value) {
|
||||||
|
return ($value / 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class ExpenseController extends Controller
|
||||||
'date' => 'required|date',
|
'date' => 'required|date',
|
||||||
'reference' => 'required|string|max:255|unique:expenses,reference',
|
'reference' => 'required|string|max:255|unique:expenses,reference',
|
||||||
'category_id' => 'required',
|
'category_id' => 'required',
|
||||||
'amount' => 'required|integer',
|
'amount' => 'required|numeric|max:2147483647',
|
||||||
'details' => 'nullable|string|max:1000'
|
'details' => 'nullable|string|max:1000'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class ExpenseController extends Controller
|
||||||
'date' => 'required|date',
|
'date' => 'required|date',
|
||||||
'reference' => 'required|string|max:255|unique:expenses,reference,' . $expense->id,
|
'reference' => 'required|string|max:255|unique:expenses,reference,' . $expense->id,
|
||||||
'category_id' => 'required',
|
'category_id' => 'required',
|
||||||
'amount' => 'required|integer',
|
'amount' => 'required|numeric|max:2147483647',
|
||||||
'details' => 'nullable|string|max:1000'
|
'details' => 'nullable|string|max:1000'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<form action="{{ route('expenses.store') }}" method="POST">
|
<form id="expense-form" action="{{ route('expenses.store') }}" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="amount">Amount <span class="text-danger">*</span></label>
|
<label for="amount">Amount <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" name="amount" required>
|
<input id="amount" type="text" class="form-control" name="amount" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,3 +71,26 @@
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#amount').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
$('#amount').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#expense-form').submit(function () {
|
||||||
|
var amount = $('#amount').maskMoney('unmasked')[0];
|
||||||
|
$('#amount').val(amount);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<form action="{{ route('expenses.update', $expense) }}" method="POST">
|
<form id="expense-form" action="{{ route('expenses.update', $expense) }}" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
@method('patch')
|
@method('patch')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -54,16 +54,14 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="amount">Amount <span class="text-danger">*</span></label>
|
<label for="amount">Amount <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" name="amount" required value="{{ $expense->amount }}">
|
<input id="amount" type="text" class="form-control" name="amount" required value="{{ $expense->amount }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="details">Details</label>
|
<label for="details">Details</label>
|
||||||
<textarea class="form-control" rows="6" name="details">
|
<textarea class="form-control" rows="6" name="details">{{ $expense->details }}</textarea>
|
||||||
{{ $expense->details }}
|
|
||||||
</textarea>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -73,3 +71,27 @@
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#amount').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
$('#amount').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#amount').maskMoney('mask');
|
||||||
|
|
||||||
|
$('#expense-form').submit(function () {
|
||||||
|
var amount = $('#amount').maskMoney('unmasked')[0];
|
||||||
|
$('#amount').val(amount);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace Modules\People\Database\Seeders;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Modules\People\Entities\Customer;
|
||||||
|
use Modules\People\Entities\Supplier;
|
||||||
|
|
||||||
class PeopleDatabaseSeeder extends Seeder
|
class PeopleDatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
@ -14,8 +16,7 @@ class PeopleDatabaseSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
Model::unguard();
|
Customer::factory()->count(15)->create();
|
||||||
|
Supplier::factory()->count(6)->create();
|
||||||
// $this->call("OthersTableSeeder");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
namespace Modules\People\Database\factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class CustomerFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = \Modules\People\Entities\Customer::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'customer_name' => $this->faker->name(),
|
||||||
|
'customer_email' => $this->faker->safeEmail(),
|
||||||
|
'customer_phone' => $this->faker->phoneNumber(),
|
||||||
|
'city' => $this->faker->city(),
|
||||||
|
'country' => $this->faker->country(),
|
||||||
|
'address' => $this->faker->streetAddress()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
namespace Modules\People\Database\factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class SupplierFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = \Modules\People\Entities\Supplier::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'supplier_name' => $this->faker->name(),
|
||||||
|
'supplier_email' => $this->faker->safeEmail(),
|
||||||
|
'supplier_phone' => $this->faker->phoneNumber(),
|
||||||
|
'city' => $this->faker->city(),
|
||||||
|
'country' => $this->faker->country(),
|
||||||
|
'address' => $this->faker->streetAddress()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,4 +12,8 @@ class Customer extends Model
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
protected static function newFactory() {
|
||||||
|
return \Modules\People\Database\factories\CustomerFactory::new();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,7 @@ class Supplier extends Model
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
protected static function newFactory() {
|
||||||
|
return \Modules\People\Database\factories\SupplierFactory::new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CustomersController extends Controller
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'customer_name' => 'required|string|max:255',
|
'customer_name' => 'required|string|max:255',
|
||||||
'customer_phone' => 'required|numeric',
|
'customer_phone' => 'required|max:255',
|
||||||
'customer_email' => 'required|email|max:255',
|
'customer_email' => 'required|email|max:255',
|
||||||
'city' => 'required|string|max:255',
|
'city' => 'required|string|max:255',
|
||||||
'country' => 'required|string|max:255',
|
'country' => 'required|string|max:255',
|
||||||
|
@ -72,7 +72,7 @@ class CustomersController extends Controller
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'customer_name' => 'required|string|max:255',
|
'customer_name' => 'required|string|max:255',
|
||||||
'customer_phone' => 'required|numeric',
|
'customer_phone' => 'required|max:255',
|
||||||
'customer_email' => 'required|email|max:255',
|
'customer_email' => 'required|email|max:255',
|
||||||
'city' => 'required|string|max:255',
|
'city' => 'required|string|max:255',
|
||||||
'country' => 'required|string|max:255',
|
'country' => 'required|string|max:255',
|
||||||
|
|
|
@ -31,7 +31,7 @@ class SuppliersController extends Controller
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'supplier_name' => 'required|string|max:255',
|
'supplier_name' => 'required|string|max:255',
|
||||||
'supplier_phone' => 'required|numeric',
|
'supplier_phone' => 'required|max:255',
|
||||||
'supplier_email' => 'required|email|max:255',
|
'supplier_email' => 'required|email|max:255',
|
||||||
'city' => 'required|string|max:255',
|
'city' => 'required|string|max:255',
|
||||||
'country' => 'required|string|max:255',
|
'country' => 'required|string|max:255',
|
||||||
|
@ -72,7 +72,7 @@ class SuppliersController extends Controller
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'supplier_name' => 'required|string|max:255',
|
'supplier_name' => 'required|string|max:255',
|
||||||
'supplier_phone' => 'required|numeric',
|
'supplier_phone' => 'required|max:255',
|
||||||
'supplier_email' => 'required|email|max:255',
|
'supplier_email' => 'required|email|max:255',
|
||||||
'city' => 'required|string|max:255',
|
'city' => 'required|string|max:255',
|
||||||
'country' => 'required|string|max:255',
|
'country' => 'required|string|max:255',
|
||||||
|
|
|
@ -24,4 +24,20 @@ class Product extends Model implements HasMedia
|
||||||
$this->addMediaCollection('default')
|
$this->addMediaCollection('default')
|
||||||
->useFallbackUrl('/images/fallback_product_image.png');
|
->useFallbackUrl('/images/fallback_product_image.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setProductCostAttribute($value) {
|
||||||
|
$this->attributes['product_cost'] = ($value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProductCostAttribute($value) {
|
||||||
|
return ($value / 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setProductPriceAttribute($value) {
|
||||||
|
$this->attributes['product_price'] = ($value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProductPriceAttribute($value) {
|
||||||
|
return ($value / 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ class ProductCreateRequest extends FormRequest
|
||||||
'product_code' => ['required', 'string', 'max:255', 'unique:products,product_code'],
|
'product_code' => ['required', 'string', 'max:255', 'unique:products,product_code'],
|
||||||
'product_barcode_symbology' => ['required', 'string', 'max:255'],
|
'product_barcode_symbology' => ['required', 'string', 'max:255'],
|
||||||
'product_quantity' => ['required', 'integer', 'min:1'],
|
'product_quantity' => ['required', 'integer', 'min:1'],
|
||||||
'product_cost' => ['required', 'integer'],
|
'product_cost' => ['required', 'numeric', 'max:2147483647'],
|
||||||
'product_price' => ['required', 'integer'],
|
'product_price' => ['required', 'numeric', 'max:2147483647'],
|
||||||
'product_stock_alert' => ['required', 'integer', 'min:0'],
|
'product_stock_alert' => ['required', 'integer', 'min:0'],
|
||||||
'product_order_tax' => ['nullable', 'integer', 'min:1'],
|
'product_order_tax' => ['nullable', 'integer', 'min:1'],
|
||||||
'product_tax_type' => ['nullable', 'integer'],
|
'product_tax_type' => ['nullable', 'integer'],
|
||||||
|
|
|
@ -20,8 +20,8 @@ class ProductUpdateRequest extends FormRequest
|
||||||
'product_code' => ['required', 'string', 'max:255', 'unique:products,product_code,' . $this->product->id],
|
'product_code' => ['required', 'string', 'max:255', 'unique:products,product_code,' . $this->product->id],
|
||||||
'product_barcode_symbology' => ['required', 'string', 'max:255'],
|
'product_barcode_symbology' => ['required', 'string', 'max:255'],
|
||||||
'product_quantity' => ['required', 'integer', 'min:1'],
|
'product_quantity' => ['required', 'integer', 'min:1'],
|
||||||
'product_cost' => ['required', 'integer'],
|
'product_cost' => ['required', 'numeric', 'max:2147483647'],
|
||||||
'product_price' => ['required', 'integer'],
|
'product_price' => ['required', 'numeric', 'max:2147483647'],
|
||||||
'product_stock_alert' => ['required', 'integer', 'min:0'],
|
'product_stock_alert' => ['required', 'integer', 'min:0'],
|
||||||
'product_order_tax' => ['nullable', 'integer', 'min:1'],
|
'product_order_tax' => ['nullable', 'integer', 'min:1'],
|
||||||
'product_tax_type' => ['nullable', 'integer'],
|
'product_tax_type' => ['nullable', 'integer'],
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<form action="{{ route('products.store') }}" method="POST" enctype="multipart/form-data">
|
<form id="product-form" action="{{ route('products.store') }}" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
@ -74,13 +74,13 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="product_cost">Cost <span class="text-danger">*</span></label>
|
<label for="product_cost">Cost <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" min="0" name="product_cost" required value="{{ old('product_cost') }}">
|
<input id="product_cost" type="text" class="form-control" name="product_cost" required value="{{ old('product_cost') }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="product_price">Price <span class="text-danger">*</span></label>
|
<label for="product_price">Price <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" min="0" name="product_price" required value="{{ old('product_price') }}">
|
<input id="product_price" type="text" class="form-control" name="product_price" required value="{{ old('product_price') }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="product_stock_alert">Alert Quantity <span class="text-danger">*</span></label>
|
<label for="product_stock_alert">Alert Quantity <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" name="product_stock_alert" required value="{{ old('stock_alert') }}" min="0">
|
<input type="number" class="form-control" name="product_stock_alert" required value="{{ old('product_stock_alert') }}" min="0">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -139,5 +139,27 @@
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
@include('includes.filepond-js')
|
@include('includes.filepond-js')
|
||||||
|
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#product_cost').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
$('#product_price').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#product-form').submit(function () {
|
||||||
|
var product_cost = $('#product_cost').maskMoney('unmasked')[0];
|
||||||
|
var product_price = $('#product_price').maskMoney('unmasked')[0];
|
||||||
|
$('#product_cost').val(product_cost);
|
||||||
|
$('#product_price').val(product_price);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="container-fluid mb-4">
|
<div class="container-fluid mb-4">
|
||||||
<form action="{{ route('products.update', $product->id) }}" method="POST" enctype="multipart/form-data">
|
<form id="product-form" action="{{ route('products.update', $product->id) }}" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('patch')
|
@method('patch')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -74,13 +74,13 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="product_cost">Cost <span class="text-danger">*</span></label>
|
<label for="product_cost">Cost <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" min="0" name="product_cost" required value="{{ $product->product_cost }}">
|
<input id="product_cost" type="text" class="form-control" min="0" name="product_cost" required value="{{ $product->product_cost }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="product_price">Price <span class="text-danger">*</span></label>
|
<label for="product_price">Price <span class="text-danger">*</span></label>
|
||||||
<input type="number" class="form-control" min="0" name="product_price" required value="{{ $product->product_price }}">
|
<input id="product_price" type="text" class="form-control" min="0" name="product_price" required value="{{ $product->product_price }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -140,5 +140,30 @@
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
@include('includes.filepond-js')
|
@include('includes.filepond-js')
|
||||||
|
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#product_cost').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
$('#product_price').maskMoney({
|
||||||
|
prefix:'$',
|
||||||
|
thousands:',',
|
||||||
|
decimal:'.',
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#product_cost').maskMoney('mask');
|
||||||
|
$('#product_price').maskMoney('mask');
|
||||||
|
|
||||||
|
$('#product-form').submit(function () {
|
||||||
|
var product_cost = $('#product_cost').maskMoney('unmasked')[0];
|
||||||
|
var product_price = $('#product_price').maskMoney('unmasked')[0];
|
||||||
|
$('#product_cost').val(product_cost);
|
||||||
|
$('#product_price').val(product_price);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ class PermissionsTableSeeder extends Seeder
|
||||||
'create_expenses',
|
'create_expenses',
|
||||||
'edit_expenses',
|
'edit_expenses',
|
||||||
'delete_expenses',
|
'delete_expenses',
|
||||||
|
//Expense Categories
|
||||||
|
'access_expense_categories',
|
||||||
//Customers
|
//Customers
|
||||||
'access_customers',
|
'access_customers',
|
||||||
'create_customers',
|
'create_customers',
|
||||||
|
@ -50,6 +52,11 @@ class PermissionsTableSeeder extends Seeder
|
||||||
'show_suppliers',
|
'show_suppliers',
|
||||||
'edit_suppliers',
|
'edit_suppliers',
|
||||||
'delete_suppliers',
|
'delete_suppliers',
|
||||||
|
//Currencies
|
||||||
|
'access_currencies',
|
||||||
|
'create_currencies',
|
||||||
|
'edit_currencies',
|
||||||
|
'delete_currencies',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($permissions as $permission) {
|
foreach ($permissions as $permission) {
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataTables;
|
||||||
|
|
||||||
|
use Modules\Currency\Entities\Currency;
|
||||||
|
use Yajra\DataTables\Html\Button;
|
||||||
|
use Yajra\DataTables\Html\Column;
|
||||||
|
use Yajra\DataTables\Html\Editor\Editor;
|
||||||
|
use Yajra\DataTables\Html\Editor\Fields;
|
||||||
|
use Yajra\DataTables\Services\DataTable;
|
||||||
|
|
||||||
|
class CurrencyDataTable extends DataTable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function dataTable($query) {
|
||||||
|
return datatables()
|
||||||
|
->eloquent($query)
|
||||||
|
->addColumn('action', function ($data) {
|
||||||
|
return view('currency::partials.actions', compact('data'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function query(Currency $model) {
|
||||||
|
return $model->newQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function html() {
|
||||||
|
return $this->builder()
|
||||||
|
->setTableId('currency-table')
|
||||||
|
->columns($this->getColumns())
|
||||||
|
->minifiedAjax()
|
||||||
|
->dom("<'row'<'col-md-3'l><'col-md-5 mb-2'B><'col-md-4'f>> .
|
||||||
|
'tr' .
|
||||||
|
<'row'<'col-md-5'i><'col-md-7 mt-2'p>>")
|
||||||
|
->orderBy(0)
|
||||||
|
->buttons(
|
||||||
|
Button::make('excel')
|
||||||
|
->text('<i class="bi bi-file-earmark-excel-fill"></i> Excel'),
|
||||||
|
Button::make('print')
|
||||||
|
->text('<i class="bi bi-printer-fill"></i> Print'),
|
||||||
|
Button::make('reset')
|
||||||
|
->text('<i class="bi bi-x-circle"></i> Reset'),
|
||||||
|
Button::make('reload')
|
||||||
|
->text('<i class="bi bi-arrow-repeat"></i> Reload')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getColumns() {
|
||||||
|
return [
|
||||||
|
Column::make('currency_name')
|
||||||
|
->className('text-center align-middle'),
|
||||||
|
|
||||||
|
Column::make('code')
|
||||||
|
->className('text-center align-middle'),
|
||||||
|
|
||||||
|
Column::make('symbol')
|
||||||
|
->className('text-center align-middle'),
|
||||||
|
|
||||||
|
Column::make('thousand_separator')
|
||||||
|
->className('text-center align-middle'),
|
||||||
|
|
||||||
|
Column::make('decimal_separator')
|
||||||
|
->className('text-center align-middle'),
|
||||||
|
|
||||||
|
Column::computed('action')
|
||||||
|
->exportable(false)
|
||||||
|
->printable(false)
|
||||||
|
->className('text-center align-middle')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function filename() {
|
||||||
|
return 'Currency_' . date('YmdHis');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
<?php
|
|
@ -35,13 +35,16 @@
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "app/",
|
"App\\": "app/",
|
||||||
"Database\\Factories\\": "database/factories/",
|
"Database\\Factories\\": "database/factories/",
|
||||||
"Database\\Seeders\\": "database/seeders/"
|
"Database\\Seeders\\": "database/seeders/",
|
||||||
}
|
"Modules\\": "Modules/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"app/Helpers/helpers.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\": "tests/",
|
"Tests\\": "tests/"
|
||||||
"Modules\\": "Modules/"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
"User": true,
|
"User": true,
|
||||||
"Adjustment": true,
|
"Adjustment": true,
|
||||||
"Expense": true,
|
"Expense": true,
|
||||||
"People": true
|
"People": true,
|
||||||
|
"Currency": true
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
|
@ -139,3 +139,18 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@endcan
|
@endcan
|
||||||
|
|
||||||
|
@can('access_currencies')
|
||||||
|
<li class="c-sidebar-nav-item c-sidebar-nav-dropdown {{ request()->routeIs('currencies*') ? 'c-show' : '' }}">
|
||||||
|
<a class="c-sidebar-nav-link c-sidebar-nav-dropdown-toggle" href="#">
|
||||||
|
<i class="c-sidebar-nav-icon bi bi-gear" style="line-height: 1;"></i> Settings
|
||||||
|
</a>
|
||||||
|
<ul class="c-sidebar-nav-dropdown-items">
|
||||||
|
<li class="c-sidebar-nav-item">
|
||||||
|
<a class="c-sidebar-nav-link {{ request()->routeIs('currencies*') ? 'c-active' : '' }}" href="{{ route('currencies.index') }}">
|
||||||
|
<i class="c-sidebar-nav-icon bi bi-cash-stack" style="line-height: 1;"></i> Currencies
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
@endcan
|
||||||
|
|
Loading…
Reference in New Issue