-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
database/migrations/2022_05_31_115042_create_subscribers_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('subscribers', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('email')->unique(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('subscribers'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
@php | ||
$meta['title'] = 'Manage Subscribers'; | ||
@endphp | ||
|
||
@extends('accounts.layouts.main', $meta) | ||
|
||
@section('main') | ||
<main class="page-content"> | ||
<div class="card"> | ||
<div class="card-header d-flex justify-content-between"> | ||
<h5>{{ $meta['title'] }}</h5> | ||
<button type="button" data-bs-toggle="modal" data-bs-target="#createNewItemModal" class="btn btn-primary btn-sm">Add | ||
New</button> | ||
</div> | ||
<div class="card-body"> | ||
<div class="table-responsive"> | ||
<table id="datatable" class="table table-striped table-bordered"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Email</th> | ||
<th>Subscribed at</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($subscribers as $subscriber) | ||
<tr> | ||
<td>{{ $loop->iteration }}</td> | ||
<td>{{ $subscriber->email }}</td> | ||
<td>{{ $subscriber->created_at }}</td> | ||
<td> | ||
<form data-form-type="deleteForm" | ||
action="{{ route('accounts.subscribers.destroy', $subscriber) }}" method="POST"> | ||
@csrf | ||
@method('delete') | ||
<button class="btn btn-sm btn-danger">Unsubscribe</button> | ||
</form> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
<!-- Modal --> | ||
<div class="modal fade" id="createNewItemModal" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<form action="{{ route('accounts.subscribers.store') }}" method="POST"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Add New Subscriber</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
@csrf | ||
<div class="mb-2"> | ||
<label>Email</label> | ||
<input type="email" name="email" placeholder="example@gmail.com" class="form-control"> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
<button type="submit" class="btn btn-primary">Save</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Modal --> | ||
<div class="modal fade" id="createNewItemModal" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<form action="{{ route('accounts.subscribers.store') }}" method="POST"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Add New Subscriber</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
@csrf | ||
<div class="mb-2"> | ||
<label>Email</label> | ||
<input type="email" name="email" placeholder="example@gmail.com" class="form-control"> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
<button type="submit" class="btn btn-primary">Save</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters