Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $check = checkWishlist($request->customer_id, $request->property_id);
     if (!$check) {
         $wishlist = new WishList();
         $wishlist->customer_id = $request->customer_id;
         $wishlist->property_id = $request->property_id;
         $wishlist->save();
         return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'object has been saved')));
     } else {
         $wishlist = WishList::where('customer_id', $request->customer_id)->where('property_id', $request->property_id)->delete();
         return response()->json(array('status' => 300, 'monolog' => array('title' => 'success', 'message' => 'object has been saved')));
     }
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     //This id is passed by the controller that calls the request class
     $wishlist = WishList::find($this->id);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['item' => 'required|unique:wishlist,item', 'link' => 'required'];
         case 'PUT':
         case 'PATCH':
             return ['item' => 'required||unique:wishlist,item,' . $wishlist->id, 'link' => 'required'];
         default:
             break;
     }
 }
Example #3
0
 public function accountWishlist()
 {
     //
     $limit = 20;
     $customer = \Auth::customer()->get();
     $wishlists = \App\WishList::where('customer_id', $customer->id)->orderBy('created_at', 'desc')->paginate($limit);
     return view('pages.account-wishlist', compact('wishlists', 'customer'));
 }
 public function changeStatus($id)
 {
     $item = WishList::find($id);
     //Change the status
     if ($item->active == true) {
         $item->active = false;
     } else {
         $item->active = true;
     }
     //Save the change
     $item->save();
     //Sending the user to the accounts page
     return redirect()->route('wishlist/index');
 }
Example #5
0
function checkWishlist($id, $property_id)
{
    $count = \App\WishList::where('customer_id', $id)->where('property_id', $property_id)->count();
    return $count > 0 ? true : false;
}
 public function postFavoriteDelete(Request $request)
 {
     $wishlist = \App\WishList::where('id', $request->id)->where('customer_id', $request->customer_id);
     $wishlist->delete();
     return 'deleted';
 }