-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Menambahkan halaman untuk admin dan banyak perbaikan bug #2
- Loading branch information
1 parent
b74ea76
commit ad48a6a
Showing
7 changed files
with
644 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\CustomUrl; | ||
use App\ShortUrl; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Crypt; | ||
|
||
class AdminController extends Controller | ||
{ | ||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('auth'); | ||
} | ||
|
||
/** | ||
* Show the application dashboard. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return view('pages/admin-dashboard'); | ||
} | ||
|
||
public function shorturl() | ||
{ | ||
$data = []; | ||
$i = 1; | ||
$short_urls = ShortUrl::with('custom_url')->get(); | ||
$short_urls->map(function ($short_url) { | ||
return $short_url->custom_url; | ||
}); | ||
foreach ($short_urls as $item) { | ||
$obj = new \stdClass(); | ||
$obj->no = $i++; | ||
$obj->id = $item->id; | ||
$obj->url = Crypt::decryptString($item->url); | ||
$obj->shorturl = Crypt::decryptString($item->shorturl); | ||
$obj->created_at = date("j F Y", strtotime($item->created_at)); | ||
array_push($data, $obj); | ||
} | ||
|
||
return view('pages/admin-shorturl', ['data' => $data]); | ||
} | ||
|
||
public function customurl() | ||
{ | ||
$data = array(); | ||
$i = 1; | ||
$short_urls = ShortUrl::with('custom_url')->get(); | ||
$short_urls->map(function ($short_url) { | ||
return $short_url->custom_url; | ||
}); | ||
foreach ($short_urls as $item) { | ||
foreach ($item->custom_url as $cus_item) { | ||
$obj = new \stdClass(); | ||
$obj->no = $i++; | ||
$obj->id = $cus_item->id; | ||
$obj->url = Crypt::decryptString($item->url); | ||
$obj->customurl = Crypt::decryptString($cus_item->customurl); | ||
$obj->created_at = date("j F Y", strtotime($cus_item->created_at)); | ||
array_push($data, $obj); | ||
} | ||
} | ||
return view('pages/admin-customurl', ['data' => $data]); | ||
} | ||
|
||
public function delete_shorturl($id) { | ||
if (Auth::check()) { | ||
try { | ||
$del = ShortUrl::query()->find($id)->delete(); | ||
} catch (\Exception $e) { | ||
return $e->getMessage(); | ||
} | ||
} | ||
return redirect(route('admin.shorturl')); | ||
} | ||
|
||
public function delete_customurl($id) { | ||
if (Auth::check()) { | ||
try { | ||
$del = CustomUrl::query()->find($id)->delete(); | ||
} catch (\Exception $e) { | ||
return $e->getMessage(); | ||
} | ||
} | ||
return redirect(route('admin.customurl')); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,173 @@ | ||
<!DOCTYPE html> | ||
<html lang="{{ app()->getLocale() }}"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<!-- CSRF Token --> | ||
<meta name="csrf-token" content="{{ csrf_token() }}"> | ||
|
||
<!-- Scripts --> | ||
<script src="{{ asset('js/app.js') }}" defer></script> | ||
|
||
<!-- Icons --> | ||
<link rel="icon" href="{{ asset('img/logo-32x32.png') }}" sizes="32x32"> | ||
<title>URL Shortener by KLAS</title> | ||
|
||
<!-- Styles --> | ||
<link type="text/css" href="{{ asset('css/normalize.css') }}" rel="stylesheet"> | ||
<link type="text/css" rel="stylesheet" href="{{ asset('css/materialize.css') }}" media="screen,projection"/> | ||
<link type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||
<style> | ||
body { | ||
display: flex; | ||
min-height: 100vh; | ||
flex-direction: column; | ||
} | ||
main { | ||
flex: 1 0 auto; | ||
} | ||
.input-field input[type=date]:focus + label, | ||
.input-field input[type=text]:focus + label, | ||
.input-field input[type=email]:focus + label, | ||
.input-field input[type=password]:focus + label { | ||
color: #e91e63; | ||
} | ||
.input-field input[type=date]:focus, | ||
.input-field input[type=text]:focus, | ||
.input-field input[type=email]:focus, | ||
.input-field input[type=password]:focus { | ||
border-bottom: 2px solid #e91e63; | ||
box-shadow: none; | ||
} | ||
</style> | ||
</head> | ||
<body id="app"> | ||
<header> | ||
</header> | ||
<main> | ||
<div class="container valign-wrapper hide-on-small-and-down" style="padding: 7%;"> | ||
<div class="z-depth-5 grey lighten-4 row" id="inibro" style="display: inline-block; padding: 32px 64px 0px 64px; border: 1px solid #EEE;"> | ||
<div class="center"> | ||
<div style="font-size: 32px;">{{ __('Login') }}</div> | ||
</div> | ||
|
||
<form method="POST" class="col s12" action="{{ route('login') }}" aria-label="{{ __('Login') }}"> | ||
@csrf | ||
|
||
<div class='row'> | ||
<div class='col s12'> | ||
</div> | ||
</div> | ||
|
||
<div class="row input-field"> | ||
<input id="email" type="email" class="validate" name="email" value="{{ old('email') }}" required> | ||
<label for="email">{{ __('E-Mail Address') }}</label> | ||
</div> | ||
|
||
<div class="row input-field"> | ||
<input id="password" type="password" class="validate" name="password" value="{{ old('password') }}" required> | ||
<label for="password">{{ __('Password') }}</label> | ||
</div> | ||
|
||
<div class="row input-field"> | ||
<p> | ||
<label> | ||
<input type="checkbox" class="filled-in" name="remember" value="{{ old('remember') ? 'checked' : '' }}"> | ||
<span>{{ __('Remember Me') }}</span> | ||
</label> | ||
</p> | ||
</div> | ||
|
||
<div class="row"> | ||
<button class="btn waves-effect waves-light" type="submit" name="action">{{ __('Login') }}</button> | ||
<span class="valign-wrapper right">Lupa password ? <br><a href="{{ route('password.request') }}">Reset Password</a></span> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<div class="hide-on-med-and-up"> | ||
<nav class="navbar-fixed-top teal z-depth-0"> | ||
<div class="nav-wrapper"> | ||
<div class="nav-title center-align" style="display: block; padding: 0;">Login</div> | ||
</div> | ||
</nav> | ||
<div class="section"></div> | ||
<div class="container"> | ||
<form method="POST" class="col s12" action="{{ route('login') }}" aria-label="{{ __('Login') }}"> | ||
@csrf | ||
|
||
<div class='row'> | ||
<div class='col s12'> | ||
</div> | ||
</div> | ||
|
||
<div class="row input-field"> | ||
<input id="email" type="email" class="validate" name="email" value="{{ old('email') }}" required> | ||
<label for="email">{{ __('E-Mail Address') }}</label> | ||
</div> | ||
|
||
<div class="row input-field"> | ||
<input id="password" type="password" class="validate" name="password" value="{{ old('password') }}" required> | ||
<label for="password">{{ __('Password') }}</label> | ||
</div> | ||
|
||
<div class="row input-field"> | ||
<p> | ||
<label> | ||
<input type="checkbox" class="filled-in" name="remember" value="{{ old('remember') ? 'checked' : '' }}"> | ||
<span>{{ __('Remember Me') }}</span> | ||
</label> | ||
</p> | ||
</div> | ||
|
||
<div class="row"> | ||
<button class="btn waves-effect waves-light" type="submit" name="action">{{ __('Login') }}</button> | ||
<span class="valign-wrapper right">Lupa password ? <br><a href="{{ route('password.request') }}">Reset Password</a></span> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</main> | ||
<!-- Footer --> | ||
<footer class="footer-copyright"> | ||
|
||
</footer> | ||
<script type="text/javascript" src="{{ asset('js/materialize.min.js') }}"></script> | ||
<script> | ||
M.AutoInit(); | ||
</script> | ||
<script> | ||
// Set the date we're counting down to | ||
let countDown = 9; | ||
let data = ["z-depth-5", "z-depth-4", "z-depth-3", "z-depth-2", "z-depth-1", "z-depth-0"]; | ||
let i = 0; | ||
// Update the count down every 1 second | ||
let x = setInterval(function () { | ||
countDown--; | ||
// Output the result in an element with id="demo" | ||
if (countDown<5) { | ||
if ( document.getElementById("inibro").classList.contains(data[i]) ) { | ||
document.getElementById("inibro").classList.replace(data[i], data[i-1]); | ||
} | ||
i--; | ||
} else { | ||
if ( document.getElementById("inibro").classList.contains(data[i]) ) { | ||
document.getElementById("inibro").classList.replace(data[i], data[i+1]); | ||
} | ||
i++; | ||
} | ||
// If the count down is over, write some text | ||
if (countDown <= 0) { | ||
clearInterval(x); | ||
if ( document.getElementById("inibro").classList.contains(data[i]) ) { | ||
document.getElementById("inibro").classList.replace(data[i], "z-depth-5"); | ||
} | ||
} | ||
}, 100); | ||
</script> | ||
</body> | ||
</html> |
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,47 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-8"> | ||
<div class="card"> | ||
<div class="card-header">{{ __('Reset Password') }}</div> | ||
|
||
<div class="card-body"> | ||
@if (session('status')) | ||
<div class="alert alert-success" role="alert"> | ||
{{ session('status') }} | ||
</div> | ||
@endif | ||
|
||
<form method="POST" action="{{ route('password.email') }}" aria-label="{{ __('Reset Password') }}"> | ||
@csrf | ||
|
||
<div class="form-group row"> | ||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required> | ||
|
||
@if ($errors->has('email')) | ||
<span class="invalid-feedback" role="alert"> | ||
<strong>{{ $errors->first('email') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row mb-0"> | ||
<div class="col-md-6 offset-md-4"> | ||
<button type="submit" class="btn btn-primary"> | ||
{{ __('Send Password Reset Link') }} | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</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,65 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-8"> | ||
<div class="card"> | ||
<div class="card-header">{{ __('Reset Password') }}</div> | ||
|
||
<div class="card-body"> | ||
<form method="POST" action="{{ route('password.request') }}" aria-label="{{ __('Reset Password') }}"> | ||
@csrf | ||
|
||
<input type="hidden" name="token" value="{{ $token }}"> | ||
|
||
<div class="form-group row"> | ||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email ?? old('email') }}" required autofocus> | ||
|
||
@if ($errors->has('email')) | ||
<span class="invalid-feedback" role="alert"> | ||
<strong>{{ $errors->first('email') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required> | ||
|
||
@if ($errors->has('password')) | ||
<span class="invalid-feedback" role="alert"> | ||
<strong>{{ $errors->first('password') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row"> | ||
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label> | ||
|
||
<div class="col-md-6"> | ||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group row mb-0"> | ||
<div class="col-md-6 offset-md-4"> | ||
<button type="submit" class="btn btn-primary"> | ||
{{ __('Reset Password') }} | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |
Oops, something went wrong.