Skip to content

Commit

Permalink
subscriber crud
Browse files Browse the repository at this point in the history
  • Loading branch information
indpurvesh committed Dec 31, 2021
1 parent 3552da9 commit c832c34
Show file tree
Hide file tree
Showing 24 changed files with 710 additions and 19 deletions.
4 changes: 4 additions & 0 deletions config/avored.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use AvoRed\Framework\Graphql\Mutations\Customer\CreateSubscriberMutation;
use AvoRed\Framework\Graphql\Queries\CartItems;
use AvoRed\Framework\Graphql\Queries\CartItemsQuery;
use AvoRed\Framework\Graphql\Types\SubscriberType;

return [

Expand Down Expand Up @@ -66,6 +68,7 @@
'shippingQuery' => \AvoRed\Framework\Graphql\Queries\ShippingQuery::class,
],
'mutation' => [
'CreateSubscriberMutation' => CreateSubscriberMutation::class,
'register' => \AvoRed\Framework\Graphql\Mutations\Auth\RegisterMutation::class,
'login' => \AvoRed\Framework\Graphql\Mutations\Auth\LoginMutation::class,
'customerUpdate' => \AvoRed\Framework\Graphql\Mutations\Customer\CustomerUpdateMutation::class,
Expand Down Expand Up @@ -103,6 +106,7 @@
'cartProduct' => AvoRed\Framework\Graphql\Types\CartProductType::class,
'payment' => AvoRed\Framework\Graphql\Types\PaymentType::class,
'shipping' => AvoRed\Framework\Graphql\Types\ShippingType::class,
'subscriber' => SubscriberType::class,
],
],
];
10 changes: 10 additions & 0 deletions database/migrations/2017_03_29_000000_avored_framework_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ public function up()
$table->foreign('product_id')->references('id')->on('products');
});

Schema::create('subscribers', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('customer_id')->nullable()->default(null);
$table->string('email')->nullable()->default(null)->unique();
$table->enum('status', ['ENABLED', 'DISABLED'])->default('ENABLED');
$table->timestamps();
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
});

$path = __DIR__.'/../../assets/countries.json';
$json = json_decode(file_get_contents($path), true);
foreach ($json as $country) {
Expand All @@ -298,6 +307,7 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('subscribers');
Schema::dropIfExists('visitors');
Schema::dropIfExists('category_product');
Schema::dropIfExists('documents');
Expand Down
5 changes: 4 additions & 1 deletion resources/lang/en/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@
'image_path' => 'Image',
'upload_file' => 'Upload File',
'drag_and_drop' => 'drag and drop',
'png_jpg_gif_up_to_10mb' => 'PNG, JPG, GIF up to 10MB'
'png_jpg_gif_up_to_10mb' => 'PNG, JPG, GIF up to 10MB',
'subscriber' => 'Subscriber',
'enabled' => 'Enabled',
'disabled' => 'Disabled',
];
4 changes: 3 additions & 1 deletion resources/views/user/staff/_fields.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
@endif
</div>


<div class="mt-3">
<x-avored::form.upload
name="image_path"
value="{{ optional($staff->imagePath)->url ?? '' }}"
value="{{ (isset($staff) && $staff->imagePath->url) ? $staff->imagePath->url : '' }}"
label="{{ __('avored::system.image_path') }}"
></x-avored::form.upload>
</div>


<div class="mt-3">
<x-avored::form.select
name="role_id"
Expand Down
24 changes: 24 additions & 0 deletions resources/views/user/subscriber/_fields.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="flex w-full mt-3">
<x-avored::form.input
name="email"
value="{{ $subscriber->email ?? '' }}"
label="{{ __('avored::system.email') }}"
></x-avored::form.input>
</div>


<div class="flex w-full mt-3">
<x-avored::form.select
name="status"
value="{{ $subscriber->status ?? '' }}"
label="{{ __('avored::system.status') }}"
>
<option {{ (isset($subscriber) && $subscriber->status === 'ENABLED') ? 'selected' : ''}} value="ENABLED">
{{ __('avored::system.enabled') }}
</option>
<option {{ (isset($subscriber) && $subscriber->status === 'DISABLED') ? 'selected' : ''}} value="DISABLED">
{{ __('avored::system.disabled') }}
</option>

</x-avored::form.select>
</div>
53 changes: 53 additions & 0 deletions resources/views/user/subscriber/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<x-avored::layout>
<div>
<div class="p-5">
<div class="flex w-full">
<h2 class="text-2xl text-red-700 font-semibold">
{{ __('avored::system.create') }} {{ __('avored::system.subscriber') }}
</h2>

</div>

<div class="mt-5 w-full">
<x-avored::form.form action="{{ route('admin.subscriber.store') }}" method="POST">

@foreach ($tabs as $tab)
<div class="w-full border rounded">
<div class="p-4 border-b">
<div class="flex w-full">
<span class="text-lg text-red-500 font-semibold">
{{ $tab->label() }}
</span>
<span class="ml-auto">

</span>
</div>

</div>
<div class="p-4">
@php
$path = $tab->view();
@endphp
@include($path)
</div>
</div>
@endforeach

<div class="mt-6 flex">
<button type="submit"
class="flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-500 focus:outline-none focus:border-red-700 focus:shadow-outline-red active:bg-red-700">

{{ __('avored::system.create') }}
</button>

<x-avored::link url="{{ route('admin.subscriber.index') }}" class="ml-3" style="button-default">
Cancel
</x-avored::link>
</div>
</x-avored::form.form>
</div>
</div>

</div>

</x-avored::layout>
50 changes: 50 additions & 0 deletions resources/views/user/subscriber/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<x-avored::layout>
<div>
<div class="p-5">
<div class="flex w-full">
<h2 class="text-2xl text-red-700 font-semibold">
{{ __('avored::system.edit') }} {{ __('avored::system.subscriber') }}
</h2>

</div>

<div class="mt-5 w-full">
<x-avored::form.form action="{{ route('admin.subscriber.update', $subscriber) }}" method="PUT">
@foreach ($tabs as $tab)
<div class="w-full border rounded">
<div class="p-4 border-b">
<div class="flex w-full">
<span class="text-lg text-red-500 font-semibold">
{{ $tab->label() }}
</span>
<span class="ml-auto">

</span>
</div>

</div>
<div class="p-4">
@php
$path = $tab->view();
@endphp
@include($path)
</div>
</div>
@endforeach

<div class="mt-6 flex">
<button type="submit"
class="flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-500 focus:outline-none focus:border-red-700 focus:shadow-outline-red active:bg-red-700">

{{ __('avored::system.save') }}
</button>

<x-avored::link url="{{ route('admin.subscriber.index') }}" class="ml-3" style="button-default">
{{ __('avored::system.cancel') }}
</x-avored::link>
</div>
</x-avored::form.form>
</div>
</div>
</div>
</x-avored::layout>
132 changes: 132 additions & 0 deletions resources/views/user/subscriber/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<x-avored::layout>
<div>
<div class="p-5">
<div class="flex w-full">
<h2 class="text-2xl text-red-700 font-semibold">
{{ __('avored::system.subscriber') }} {{ __('avored::system.list') }}
</h2>
<span class="ml-auto">
<x-avored::link url="{{ route('admin.subscriber.create') }}" style="button-primary">
{{ __('avored::system.create') }}
</x-avored::link>
</span>
</div>

<div class="w-full mt-5">
<div class="overflow-x-auto">
<x-avored::table>
<x-slot name="header">
<x-avored::table.row class="bg-gray-300">
<x-avored::table.header>
{{ __('avored::system.email') }}
</x-avored::table.header>
<x-avored::table.header>
{{ __('avored::system.status') }}
</x-avored::table.header>
<x-avored::table.header class="rounded-tr">
{{ __('avored::system.actions') }}
</x-avored::table.header>
</x-avored::table.row>
</x-slot>
<x-slot name="body">
@foreach ($subscribers as $subscriber)
<x-avored::table.row class="{{ ($loop->index % 2 == 0) ? '' : 'bg-gray-200' }}">
<x-avored::table.cell>
{{ $subscriber->email ?? '' }}
</x-avored::table.cell>
<x-avored::table.cell>
{{ $subscriber->status ?? '' }}
</x-avored::table.cell>
<x-avored::table.cell>
<div class="flex">
<x-avored::link url="{{ route('admin.subscriber.edit', $subscriber) }}">
<i class="w-5 h-5" data-feather="edit"></i>
</x-avored::link>
<span class="mx-2">|</span>
<x-avored::link
x-on:click.prevent="toggleConfirmationDialog(
true,
{{ $subscriber }},
'{{ __('avored::system.confirmation_delete_message', ['attribute_value' => $subscriber->name, 'attribute' => strtolower(__('avored::system.subscriber'))]) }}',
'{{ route('admin.subscriber.destroy', $subscriber) }}'
)"
url="{{ route('admin.subscriber.destroy', $subscriber) }}">
<i class="w-5 h-5" data-feather="trash"></i>
<x-avored::form.form
id="subscriber-destory-{{ $subscriber->id }}"
method="delete"
action="{{ route('admin.subscriber.destroy', $subscriber) }}">
</x-avored::form.form>
</x-avored::link>
</div>
</x-avored::table.cell>
</x-avored::table.row>
@endforeach
</x-slot>
</x-avored::table>
<div class="w-full">
{{ $subscribers->render() }}
</div>
</div>
</div>
</div>
<div
x-show="showAlert"
class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded absolute bottom-10 right-10"
role="alert">
<div class="flex">
<span class="block sm:inline" x-text="showAlertMessage"></span>
<span x-transition.duration.500ms x-on:click="showAlert = false" class="pl-4">
<svg class="fill-current h-6 w-6 text-green-500" role="button" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20">
<title>Close</title><
path d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z"/>
</svg>
</span>
</div>
</div>
<div x-show="showConfirmationModal"
class="min-w-screen h-screen animated fadeIn faster fixed left-0 top-0 flex justify-center items-center inset-0 z-50 outline-none focus:outline-none bg-no-repeat bg-center bg-cover"
id="modal-id">
<div class="absolute bg-black opacity-20 inset-0 z-0"></div>
<div class="w-full max-w-lg p-5 relative mx-auto my-auto rounded-xl shadow-lg bg-white ">
<!--content-->
<div class="">
<!--body-->
<div class="text-center p-5 flex-auto justify-center">
<svg xmlns="http://www.w3.org/2000/svg"
class="w-4 h-4 -m-1 flex items-center text-red-500 mx-auto"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg"
class="w-16 h-16 flex items-center text-red-500 mx-auto" viewBox="0 0 20 20" fill="currentColor">
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
clip-rule="evenodd" />
</svg>
<h2 class="text-xl font-bold py-4 ">
{{ __('avored::system.are_you_sure') }}
</h3>
<p class="text-sm text-gray-500 px-8" x-html="message">


</p>
</div>
<!--footer-->
<div class="p-3 mt-2 text-center space-x-4 md:block">
<button x-on:click="toggleConfirmationDialog(false)" class="mb-2 md:mb-0 bg-white px-5 py-2 text-sm shadow-sm font-medium tracking-wider border text-gray-600 rounded-full hover:shadow-lg hover:bg-gray-100">
{{ __('avored::system.cancel') }}
</button>
<button x-on:click="confirmation" class="mb-2 md:mb-0 bg-red-500 border border-red-500 px-5 py-2 text-sm shadow-sm font-medium tracking-wider text-white rounded-full hover:shadow-lg hover:bg-red-600">
{{ __('avored::system.delete') }}
</button>
</div>
</div>
</div>
</div>
</div>
</x-avored::layout>
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use AvoRed\Framework\System\Controllers\RoleController;
use AvoRed\Framework\User\Controllers\LoginController;
use AvoRed\Framework\User\Controllers\StaffController;
use AvoRed\Framework\User\Controllers\SubscriberController;
use Illuminate\Support\Facades\Route;

/*
Expand Down Expand Up @@ -77,6 +78,7 @@

/***************** USER ROUTES *****************/
Route::resource('staff', StaffController::class);
Route::resource('subscriber', SubscriberController::class);


/***************** ORDER ROUTES *****************/
Expand Down
Loading

0 comments on commit c832c34

Please sign in to comment.