prepare table

dev
Aji Kamaludin 1 year ago
parent eca09a6cd6
commit 935be0886f
No known key found for this signature in database
GPG Key ID: 19058F67F0083AD3

@ -23,7 +23,6 @@ class SettingController extends Controller
{
$request->validate([
'OPEN_WEBSITE_NAME' => 'required|string',
'VOUCHER_STOCK_NOTIFICATION' => 'required|numeric',
'AFFILATE_ENABLED' => 'required|in:0,1',
'AFFILATE_POIN_AMOUNT' => 'required|numeric',
'MIDTRANS_SERVER_KEY' => 'required|string',

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CashDepositLocation extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CustomerCart extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CustomerLocationFavorite extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LocationProfile extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LocationProfilePrice extends Model
{
use HasFactory;
}

@ -14,106 +14,17 @@ class Voucher extends Model
protected $fillable = [
'name',
'description',
'location_id',
'location_profile_id',
'username',
'password',
'price_poin', // harga voucher untuk ditukarkan dengan poin
'price', // harga jual
'discount',
'display_price', //yang di input user
'quota',
'profile',
'comment',
'expired',
'expired_unit',
'is_sold', //menandakan sudah terjual atau belum
// batch pada saat import , jadi ketika user ingin beli akan tetapi sudah sold ,
// maka akan dicarikan voucher lain dari batch yang sama
'batch_id',
];
protected $appends = ['display_quota', 'display_expired', 'validate_price', 'validate_display_price'];
protected static function booted(): void
{
static::creating(function (Voucher $voucher) {
if ($voucher->batch_id == '') {
$voucher->batch_id = Str::ulid();
}
if ($voucher->price == '') {
$price = $voucher->display_price;
if ($voucher->discount > 0) {
$price = $voucher->display_price - round($voucher->display_price * ($voucher->discount / 100), 2);
}
$voucher->price = $price;
}
});
static::updating(function (Voucher $voucher) {
$price = $voucher->display_price;
if ($voucher->discount > 0) {
$price = $voucher->display_price - round($voucher->display_price * ($voucher->discount / 100), 2);
}
$voucher->price = $price;
});
}
public function displayQuota(): Attribute
{
return Attribute::make(get: function () {
return round($this->quota / (1024 * 1024 * 1024), 2) . ' GB';
});
}
public function displayExpired(): Attribute
{
return Attribute::make(get: function () {
return $this->expired . ' ' . $this->expired_unit;
});
}
public function validatePrice(): Attribute
{
return Attribute::make(get: function () {
if (auth('customer')->check()) {
if ($this->prices()->count() > 0) {
$price = $this->prices()->where('customer_level_id', auth()->user()->customer_level_id)->value('price');
return $price;
}
}
return $this->price;
});
}
public function validateDisplayPrice(): Attribute
{
return Attribute::make(get: function () {
if (auth('customer')->check()) {
if ($this->prices()->count() > 0) {
$price = $this->prices()->where('customer_level_id', auth()->user()->customer_level_id)->value('display_price');
return $price;
}
}
return $this->display_price;
});
}
public function location()
{
return $this->belongsTo(Location::class)->withTrashed();
}
public function prices()
{
return $this->hasMany(VoucherPrice::class);
}
public function shuffle_unsold()
{
$voucher = Voucher::where([

@ -1,18 +0,0 @@
<?php
namespace App\Models;
class VoucherPrice extends Model
{
protected $fillable = [
'customer_level_id',
'voucher_id',
'price',
'display_price',
];
public function level()
{
return $this->belongsTo(CustomerLevel::class, 'customer_level_id');
}
}

@ -16,20 +16,13 @@ return new class extends Migration
$table->string('name')->nullable();
$table->string('description')->nullable();
$table->ulid('location_id')->nullable();
$table->ulid('location_profile_id')->nullable();
$table->string('username')->nullable();
$table->string('password')->nullable();
$table->decimal('price_poin', 20, 2)->default(0);
$table->decimal('price', 20, 2)->default(0);
$table->decimal('discount', 20, 0)->default(0);
$table->decimal('display_price', 20, 2)->default(0);
$table->string('quota')->nullable();
$table->string('profile')->nullable();
$table->text('comment')->nullable();
$table->string('expired')->nullable();
$table->string('expired_unit')->nullable();
$table->smallInteger('is_sold')->default(0);
$table->ulid('batch_id')->nullable();
$table->text('additional_json')->nullable();
$table->timestamps();

@ -30,6 +30,7 @@ return new class extends Migration
$table->string('identity_image')->nullable();
$table->ulid('customer_level_id')->nullable();
$table->text('google_oauth_response')->nullable();
$table->timestamp('poin_expired_at')->nullable();
$table->timestamps();
$table->softDeletes();

@ -18,6 +18,8 @@ return new class extends Migration
$table->string('bank_name')->nullable();
$table->string('holder_name')->nullable();
$table->string('account_number')->nullable();
$table->string('logo')->nullable();
$table->decimal('admin_fee', 20, 2)->nullable();
$table->timestamps();
$table->softDeletes();

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('location_profiles', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->ulid('location_id')->nullable();
$table->string('name')->nullable();
$table->string('quota')->nullable();
$table->string('display_note')->nullable();
$table->string('expired')->nullable();
$table->string('expired_unit')->nullable();
$table->string('description')->nullable();
$table->integer('min_stock')->default(0);
$table->decimal('price', 20, 2)->default(0);
$table->decimal('display_price', 20, 2)->default(0);
$table->decimal('discount', 20, 0)->default(0);
$table->decimal('price_poin', 20, 2)->default(0);
$table->decimal('bonus_poin', 20, 2)->default(0);
$table->timestamps();
$table->softDeletes();
$table->ulid('created_by')->nullable();
$table->ulid('updated_by')->nullable();
$table->ulid('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('location_profiles');
}
};

@ -11,13 +11,16 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('voucher_prices', function (Blueprint $table) {
Schema::create('location_profile_prices', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->ulid('location_profile_id')->nullable();
$table->ulid('customer_level_id')->nullable();
$table->ulid('voucher_id')->nullable();
$table->decimal('price', 20, 2)->default(0);
$table->decimal('display_price', 20, 2)->default(0);
$table->decimal('discount', 20, 0)->default(0);
$table->decimal('price_poin', 20, 2)->default(0);
$table->decimal('bonus_poin', 20, 2)->default(0);
$table->timestamps();
$table->softDeletes();
@ -32,6 +35,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('voucher_prices');
Schema::dropIfExists('location_profile_prices');
}
};

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('customer_location_favorites', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->ulid('location_id')->nullable();
$table->ulid('customer_id')->nullable();
$table->timestamps();
$table->softDeletes();
$table->ulid('created_by')->nullable();
$table->ulid('updated_by')->nullable();
$table->ulid('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('customer_location_favorites');
}
};

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('customer_carts', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->ulid('customer_id')->nullable();
$table->ulid('sale_id')->nullable();
$table->string('entity_type')->nullable();
$table->ulid('entity_id')->nullable();
$table->decimal('price', 20, 2)->default(0);
$table->integer('quantity')->default(0);
$table->text('additional_info_json')->nullable();
$table->timestamps();
$table->softDeletes();
$table->ulid('created_by')->nullable();
$table->ulid('updated_by')->nullable();
$table->ulid('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('customer_carts');
}
};

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cash_deposit_locations', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->string('name')->nullable();
$table->text('address')->nullable();
$table->string('phone')->nullable();
$table->string('gmap_url', 1000)->nullable();
$table->string('image')->nullable();
$table->text('description')->nullable();
$table->string('open_hour')->nullable();
$table->string('close_hour')->nullable();
$table->smallInteger('is_active')->nullable();
$table->timestamps();
$table->softDeletes();
$table->ulid('created_by')->nullable();
$table->ulid('updated_by')->nullable();
$table->ulid('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cash_deposit_locations');
}
};

@ -24,14 +24,23 @@ class InstallationSeed extends Seeder
['key' => 'AFFILATE_ENABLED', 'value' => '0', 'type' => 'checkbox'],
['key' => 'AFFILATE_POIN_AMOUNT', 'value' => '0', 'type' => 'text'],
['key' => 'AFFILATE_DOWNLINE_POIN_AMOUNT', 'value' => '0', 'type' => 'text'],
['key' => 'MIDTRANS_SERVER_KEY', 'value' => 'SB-Mid-server-UA0LQbY4aALV0CfLLX1v7xs8', 'type' => 'text'],
['key' => 'MIDTRANS_CLIENT_KEY', 'value' => 'SB-Mid-client-xqqkspzoZOM10iUG', 'type' => 'text'],
['key' => 'MIDTRANS_MERCHANT_ID', 'value' => 'G561244367', 'type' => 'text'],
['key' => 'MIDTRANS_LOGO', 'value' => 'sample/midtrans_logo.png', 'type' => 'image'],
['key' => 'MIDTRANS_ENABLED', 'value' => '0', 'type' => 'text'],
['key' => 'MIDTRANS_ADMIN_FEE', 'value' => '2500', 'type' => 'text'],
['key' => 'VOUCHER_STOCK_NOTIFICATION', 'value' => '10', 'type' => 'text'],
// ['key' => 'VOUCHER_STOCK_NOTIFICATION', 'value' => '10', 'type' => 'text'],
['key' => 'ENABLE_CASH_DEPOSIT', 'value' => '0', 'type' => 'text'],
['key' => 'ENABLE_MANUAL_TRANSFER', 'value' => '0', 'type' => 'text'],
['key' => 'MAX_MANUAL_TRANSFER_TIMEOUT', 'value' => '2', 'type' => 'text'], //dalam jam
['key' => 'MANUAL_TRANSFER_OPEN_HOUR', 'value' => '06:00', 'type' => 'text'],
['key' => 'MANUAL_TRANSFER_CLOSE_HOUR', 'value' => '23:00', 'type' => 'text'],
['key' => 'MAX_POINT_EXPIRED', 'value' => '90', 'type' => 'text'], //dalam hari
];
foreach ($settings as $setting) {

@ -0,0 +1,51 @@
import React from 'react'
import { isEmpty } from 'lodash'
import { HiFilter } from 'react-icons/hi'
export default function FormLocation({
type,
name,
onChange,
value,
label,
autoComplete,
autoFocus,
placeholder,
disabled,
readOnly,
onKeyDownCapture,
max,
min,
}) {
return (
<>
<label
htmlFor={name}
className="block mb-2 text-sm font-medium text-gray-900 dark:text-white"
>
{label}
</label>
<div className="relative">
<input
id={name}
type="text"
className="mb-2 bg-gray-50 border text-gray-900 text-sm rounded-lg block w-full p-2.5 dark:bg-gray-700 dark:placeholder-gray-400 dark:text-white active:ring-blue-500 focus:ring-blue-500 focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500"
onChange={onChange}
name={name}
value={value}
autoComplete={autoComplete ? 'on' : 'off'}
autoFocus={autoFocus}
placeholder={placeholder}
disabled={disabled}
readOnly={readOnly}
onKeyDownCapture={onKeyDownCapture}
max={max}
min={min}
/>
<div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
<HiFilter />
</div>
</div>
</>
)
}

@ -5,10 +5,12 @@ import CustomerLayout from '@/Layouts/CustomerLayout'
import { HiOutlineBell } from 'react-icons/hi2'
import UserBanner from './UserBanner'
import VoucherCard from './VoucherCard'
import FormLocation from '../Components/FormLocation'
import { HiXCircle } from 'react-icons/hi'
const GuestBanner = () => {
const {
props: { setting },
props: { setting, notification_count },
} = usePage()
return (
<div>
@ -21,7 +23,7 @@ const GuestBanner = () => {
<HiOutlineBell className="text-white w-7 h-7" />
<div>
<div className="bg-white text-blue-700 rounded-lg px-1 text-xs -ml-2.5">
0
{notification_count}
</div>
</div>
</div>
@ -125,8 +127,29 @@ export default function Index(props) {
</div>
<div className="w-full flex flex-col">
<div className="w-full space-x-2 px-2 mb-2">
<FormLocation placeholder="Cari Lokasi" value={''} />
</div>
{/* chips */}
<div className="w-full flex flex-row overflow-y-scroll space-x-2 px-2">
<div className="w-full flex flex-row overflow-y-scroll space-x-2 px-4">
<div
className={`px-2 py-1 rounded-2xl text-white bg-blue-600 border border-blue-800`}
>
Semua
</div>
<div
className={`px-2 py-1 rounded-2xl bg-blue-100 border border-blue-200`}
>
Favorite
</div>
<div className="flex flex-row items-center gap-1 px-2 py-1 rounded-2xl bg-blue-100 border border-blue-200">
<div>Farid Net</div>
<div>
<HiXCircle className="h-5 w-5 text-red-700" />
</div>
</div>
</div>
{/* <div className="w-full flex flex-row overflow-y-scroll space-x-2 px-2">
{locations.map((location) => (
<div
onClick={() => handleSelectLoc(location)}
@ -140,7 +163,7 @@ export default function Index(props) {
{location.name}
</div>
))}
</div>
</div> */}
{/* voucher */}
<div className="flex flex-col w-full px-3 mt-3 space-y-2">

@ -13,10 +13,6 @@ export default function General(props) {
const { setting, midtrans_notification_url } = props
const { data, setData, post, reset, processing, errors } = useForm({
OPEN_WEBSITE_NAME: extractValue(setting, 'OPEN_WEBSITE_NAME'),
VOUCHER_STOCK_NOTIFICATION: extractValue(
setting,
'VOUCHER_STOCK_NOTIFICATION'
),
AFFILATE_ENABLED: extractValue(setting, 'AFFILATE_ENABLED'),
AFFILATE_POIN_AMOUNT: extractValue(setting, 'AFFILATE_POIN_AMOUNT'),
MIDTRANS_SERVER_KEY: extractValue(setting, 'MIDTRANS_SERVER_KEY'),
@ -71,17 +67,6 @@ export default function General(props) {
error={errors.OPEN_WEBSITE_NAME}
/>
</div>
<div className="p-2 border rounded-xl mt-2">
<div className="font-bold mb-2">Notification</div>
<FormInput
type={'number'}
name="VOUCHER_STOCK_NOTIFICATION"
value={data.VOUCHER_STOCK_NOTIFICATION}
onChange={handleOnChange}
label="Jumlah Stok"
error={errors.VOUCHER_STOCK_NOTIFICATION}
/>
</div>
<div className="mt-2 p-2 border rounded-xl">
<div className="font-bold mb-2">Affilate</div>

Loading…
Cancel
Save