Reputation: 11
I have a table (post) in my database with (id, title, post) columns.
I have 3 records with the same title in my table but, it returns just the first record.
How to return all records with the same title using Route Model Binding?
This is my Route:
Route::get('bind/{key:title}',[RouteModelBindingController::class, 'index']);
This is my Controller Class:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Post;
class RouteModelBindingController extends Controller
{
public function index(Post $key){
return $key;
}
}
Upvotes: 1
Views: 268