You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 lines
818 B

<?php
namespace App\Http\Controllers;
use App\Models\Wish;
use Illuminate\Http\Request;
class WishController extends Controller
{
function ClaimWish(Request $request, Wish $wish) {
if($wish->claimed_by !== 0) {
return response()->json("Dieser Wunsch wurde bereits von jemandem reserviert.", 400);
}
if($wish->owner_id === $request->user()->id) {
return response()->json("Du willst dich selbst beschenken? Lass mal lieber...", 400);
}
$wish->claimed_by = $request->user()->id;
$wish->save();
return response()->json("Wunsch " . $wish->id . " erfolreich reserviert.", 200);
}
function Wishlist(Request $request) {
return Wish::where("claimed_by", 0)->where("owner_id", "!=", $request->user()->id)->get();
}
}