I have the system where I can manually change the database and the bike id will link to the favourite id and will show on the favourite page.
What I need now is to allow the user to click a favourite button on the bike img and it will save the bike for them to view on their favourites page
I have tried a few different options but can not get anything to work as yet, apart from manually changing the database to show information
this is the favourites page code:
@foreach($bike->favourites as $favourite)
<div class="grid">
<img src="{{ $bike->bike_img }}">
<div class="item {{ $bike->bike_category }} {{ $bike->bike_category2 }}">
<h2>{{ $bike->bike_name }}</h2>
<a href="{{ $bike->bike_url }}" target="_blank">Buy this bike</a>
</div></div>
@endforeach
this is where the bikes show:
@foreach($bikes as $bike)
<div class="item {{ $bike->bike_category }} {{ $bike->bike_category2 }}">
<h2>{{ $bike->bike_name }}</h2>
<img src="{{ $bike->bike_img }}"><br><br>
<a href="{{ $bike->bike_url }}" target="_blank">Buy this bike</a>
<a href="" class="favebutton"><i class="far fa-heart"></i></a>
</div>
@endforeach
I think I need the favebutton to be a form that will submit and take the user id, attach it to the favourite database which will then show on the favourites page. This would be the ideal outcome.
When the user clicks the fave button it will then bring it into the favourite database and show on the favourite page