2024-02-04 23:36:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
2025-10-07 03:10:25 +00:00
|
|
|
use App\Http\Controllers\ReaderController;
|
2024-08-04 21:38:41 +00:00
|
|
|
use App\Http\Controllers\WriterController;
|
2024-08-04 04:50:42 +00:00
|
|
|
use App\Models\Article;
|
2025-10-07 03:10:25 +00:00
|
|
|
use Illuminate\Http\Request;
|
2024-02-04 23:36:46 +00:00
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Web Routes
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
| Here is where you can register web routes for your application. These
|
|
|
|
|
| routes are loaded by the RouteServiceProvider and all of them will
|
|
|
|
|
| be assigned to the "web" middleware group. Make something great!
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Route::get('/', function () {
|
2025-03-19 21:52:49 +00:00
|
|
|
$articles = Article::where('published_at', '<', now())->latest()->limit(10)->get();
|
2025-03-19 21:40:54 +00:00
|
|
|
return view('guest.home', ['articles' => $articles]);
|
2024-02-04 23:36:46 +00:00
|
|
|
});
|
2024-08-04 04:50:42 +00:00
|
|
|
|
|
|
|
|
Route::get('/test-insert', function () {
|
|
|
|
|
return view('test-insert');
|
|
|
|
|
})->name('test-insert');
|
|
|
|
|
|
2025-10-07 03:10:25 +00:00
|
|
|
Route::get('/all-articles', function () {
|
|
|
|
|
$all_articles = Article::where('published_at', '<', now())->paginate(25);
|
2024-08-04 19:07:03 +00:00
|
|
|
return view('guest.all-articles', ['all_articles' => $all_articles]);
|
2025-10-07 03:10:25 +00:00
|
|
|
})->name('all-articles');
|
2024-08-04 19:07:03 +00:00
|
|
|
|
|
|
|
|
Route::get('/post/{article_slug}', function ($article_slug) {
|
|
|
|
|
$active_article = Article::with('author')
|
|
|
|
|
->where('published_at', '<', now())
|
|
|
|
|
->where('slug', $article_slug)
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
if(empty($active_article)) {
|
|
|
|
|
return abort(404);
|
|
|
|
|
}
|
|
|
|
|
return view('guest.article', ['article' => $active_article]);
|
|
|
|
|
})->name('article');
|
2024-08-04 21:38:41 +00:00
|
|
|
|
|
|
|
|
Route::get('/writer/login', function () {
|
|
|
|
|
return view('writer.login');
|
|
|
|
|
})->name('login');
|
|
|
|
|
|
2025-10-07 03:10:25 +00:00
|
|
|
Route::post('/subscribe', [ReaderController::class, 'subscribe'])->name('subscribe');
|
|
|
|
|
|
|
|
|
|
Route::get('/subscribe-success', function() {
|
|
|
|
|
return view('guest.subscribe-success');
|
|
|
|
|
})->name('subscribe-success');
|
|
|
|
|
|
|
|
|
|
Route::get('/subscribe-fail', function() {
|
|
|
|
|
return view('guest.subscribe-fail');
|
|
|
|
|
})->name('subscribe-fail');
|
|
|
|
|
|
2024-08-04 21:38:41 +00:00
|
|
|
Route::post('/writer/authenticate', [WriterController::class, 'authenticate'])->name('authenticate');
|
|
|
|
|
|
|
|
|
|
Route::middleware('auth')->group(function () {
|
|
|
|
|
Route::get('/writer', [WriterController::class, 'dashboard'])->name('dashboard');
|
|
|
|
|
Route::post('/logout', [WriterController::class, 'logout'])->name('logout');
|
|
|
|
|
Route::get('writer/new-article', [WriterController::class, 'newArticle'])->name('new_article');
|
2024-08-04 22:53:04 +00:00
|
|
|
Route::post('writer/live-preview', [WriterController::class, 'livePreview'])->name('live_preview');
|
2025-03-23 20:23:47 +00:00
|
|
|
Route::post('writer/save-article', [WriterController::class, 'saveArticle'])->name('save_article');
|
2024-08-04 21:38:41 +00:00
|
|
|
});
|