سلام چرا متد indexکار میکنه ولی متد createخطای404 برمیگردونه؟
اطلاعات بیشتر:
*
<?php
// app/Http/Controllers/Api/v1/ProfileController.php
namespace App\Http\Controllers\Api\v1;
use App\Models\Post;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Resources\ProfileResource;
class ProfileController extends Controller
{
public function index(User $user)
{
return new ProfileResource($user);
}
public function create()
{
return response()->json(['message' => 'This is the create method.']);
}
}
*
<?php
// routes/api.php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\v1\ProfileController;
use App\Http\Controllers\Api\v1\PostController;
Route::prefix('v1')->group(function(){
Route::get('profiles/{user}', [ProfileController::class, 'index'])->name('api.profiles.index');
Route::get('profiles/create', [ProfileController::class, 'create'])->name('api.profiles.create');
});