This commit is contained in:
2023-07-30 02:15:19 +08:00
parent 58b939f72e
commit 277a919436
28 changed files with 807 additions and 99 deletions

View File

@@ -1,10 +1,10 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Models\CountryLocale;
use App\Models\Post;
use App\Models\Author;
use App\Models\Category;
use App\Models\CountryLocale;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
@@ -17,30 +17,44 @@
|
*/
Route::post('login', [App\Http\Controllers\Auth\LoginController::class, 'login'])->name('api.auth.login.post');
Route::post('login', [App\Http\Controllers\Auth\LoginController::class, 'login'])->name('api.auth.login.post');
Route::middleware('auth:sanctum')->post('logout',[App\Http\Controllers\Auth\LoginController::class,'logout'])->name('api.auth.logout.post');
Route::middleware('auth:sanctum')->post('logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])->name('api.auth.logout.post');
Route::prefix('admin')->middleware('auth:sanctum')->group(function () {
Route::get('/country-locales', function() {
Route::get('/post/{id}', function ($id) {
$post = Post::with('post_category.category')->find($id);
return response()->json(compact('post'));
})->name('api.admin.post.get');
Route::get('/country-locales', function () {
$country_locales = CountryLocale::where('enabled', true)->get();
$default_locale_slug = 'my';
return response()->json(compact('country_locales','default_locale_slug'));
return response()->json(compact('country_locales', 'default_locale_slug'));
})->name('api.admin.country-locales');
})->name('api.admin.country-locales');
Route::get('/categories/{country_locale_slug}', function($country_locale_slug) {
Route::get('/categories/{country_locale_slug}', function ($country_locale_slug) {
$categories = Category::where('enabled', true)->where('country_locale_slug', $country_locale_slug)->get();
return response()->json(compact('categories'));
})->name('api.admin.categories');
})->name('api.admin.categories');
Route::get('/authors', function () {
$authors = Author::where('enabled', true)->get();
return response()->json(compact('authors'));
})->name('api.admin.authors');
Route::post('image/upload', [App\Http\Controllers\Services\ImageUploadController::class, 'index'])->name('api.admin.upload.cloud.image');
Route::post('admin/post/upsert', [App\Http\Controllers\Admin\PostController::class, 'postUpsert'])->name('api.admin.post.upsert');
});
Route::post('admin/image/upload', [App\Http\Controllers\Services\ImageUploadController::class, 'index'])->name('api.admin.upload.cloud.image');