Skip to content

Commit 2078174

Browse files
committed
feat: added web ui to create links without api
1 parent 6e287d6 commit 2078174

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

app/Http/Controllers/DashboardController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,14 @@ public function get(Request $request)
1414

1515
}
1616

17+
public function newlink(Request $request){
18+
return view('newLink');
19+
}
20+
21+
public function webStore(Request $request){
22+
$link = new LinkController();
23+
$link->store($request);
24+
return redirect()->route('dashboard')->with('success', 'Link created successfully!');
25+
}
26+
1727
}

resources/views/layouts/navigation.blade.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
<x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
1616
{{ __('Dashboard') }}
1717
</x-nav-link>
18+
<x-nav-link :href="route('newlink')" :active="request()->routeIs('newlink')">
19+
{{ __('New Link') }}
20+
</x-nav-link>
1821
<x-nav-link :href="route('tokens')" :active="request()->routeIs('tokens')">
19-
{{ __('Tokens') }}
22+
{{ __('API Tokens') }}
2023
</x-nav-link>
2124
</div>
2225
</div>

resources/views/newLink.blade.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<x-app-layout>
2+
<x-slot name="header">
3+
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
4+
{{ __('Create a new link') }} </h2>
5+
</x-slot>
6+
<div class="py-12">
7+
8+
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
9+
<span class="text-xl font-medium text-white title-font mb-5">
10+
{{-- form --}}
11+
<form method="POST" action="{{ route('web-links.store') }}">
12+
@csrf
13+
{{-- input for url --}}
14+
<div class="mb-4">
15+
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100"> {{ __('Enter the long URL to shrink') }} </h2>
16+
<x-text-input id="long_url" class="block mt-1 w-full" type="url" name="long_url" :value="old('title')"
17+
required autofocus />
18+
</div>
19+
{{-- submit --}}
20+
<div class="flex items-center justify-end mt-4">
21+
<x-primary-button class="ml-4">
22+
{{ __('Create') }}
23+
</x-primary-button>
24+
</div>
25+
</span>
26+
</div>
27+
28+
</div>
29+
</x-app-layout>

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
|
1616
*/
1717

18-
Route::post('/link', [LinkController::class, 'store'])->middleware('auth:sanctum');
18+
Route::post('/link', [LinkController::class, 'store'])->middleware('auth:sanctum')->name('link.store');

routes/web.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
Route::middleware(['auth', 'verified'])->group(function () {
2626
Route::get('/dashboard', [DashboardController::class, 'get'])->name('dashboard');
27+
28+
Route::get('/newlink', [DashboardController::class, 'newlink'])->name('newlink');
29+
Route::post('/newlink', [DashboardController::class, 'webStore'])->name('web-links.store');
30+
2731

2832
Route::get('/tokens', [TokenController::class, 'get'])->name('tokens');
2933

0 commit comments

Comments
 (0)