示例#1
0
 /**
  * Destroy the given task.
  *
  * @param  Request  $request
  * @param  Task  $task
  * @return Response
  */
 public function destroy(Request $request, Task $task)
 {
     if (\Auth::id() == $task->user_id) {
         $task->delete();
     }
     return redirect('/tasks');
 }
示例#2
0
 /**
  * Responds to requests to
  */
 public function getPage($id = null)
 {
     if ($id != null) {
         // find the item in the added_items table
         $item = \App\AddedItem::where('id', '=', $id)->find($id);
         $itemAsArray = $item->toArray();
         // update the added_items table
         if ($itemAsArray) {
             $item->make_public = TRUE;
             // save changes
             $item->save();
             \Session::flash('flash_message', 'You successfully made ' . $item->item . ' public for sale!');
         }
         // add the item to the public_items table
         $publicItem = new \App\PublicItem();
         $publicItem->item = $itemAsArray['item'];
         $publicItem->category = $itemAsArray['category'];
         $publicItem->one_line_description = $itemAsArray['one_line_description'];
         $publicItem->price = $itemAsArray['price'];
         $publicItem->detailed_description = $itemAsArray['detailed_description'];
         $publicItem->user_id = \Auth::id();
         $publicItem->save();
     }
     // fetch the items from the public_items table
     $items = \App\PublicItem::where('bought', '=', 0)->get();
     //dump($items->toArray());
     $itemsArray = $items->toArray();
     //dump($itemsArray);
     return view('pongo.browse_items')->with('items', $itemsArray);
 }
示例#3
0
 /**
  * Destroy the given order.
  *
  * @param  Request  $request
  * @param  Order  $order
  * @return Response
  */
 public function destroy(Request $request, Order $order)
 {
     if (\Auth::id() == $order->user_id) {
         $order->delete();
     }
     return redirect('/orders');
 }
示例#4
0
 public function mrbs()
 {
     $user = User::find(\Auth::id());
     $userName = $user->name;
     $passwd = $user->password;
     return view('mrbs.mrbs')->with('userName', $userName)->with('passwd', $passwd);
 }
    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store(Request $request)
    {
        $this->validate($request, StockMovement::$rules);
        // Has Combination?
        if ($request->has('group')) {
            $groups = $request->input('group');
            $q = '';
            foreach ($groups as $option) {
                $q .= ' (co.option_id = ' . $option . ') or';
            }
            $q = substr($q, 0, -2);
            $q = 'SELECT combination_id, COUNT(combination_id) tot FROM `combinations` as c
					left join combination_option as co
					on co.combination_id = c.id
					WHERE c.product_id = ' . $request->input('product_id') . '
					AND ( ' . $q . ' )
					GROUP BY combination_id ORDER BY tot DESC
					LIMIT 1';
            $result = DB::select(DB::raw($q));
            // echo $q.'<br>';echo_r($result); die();
            $combination_id = $result[0]->combination_id;
        } else {
            $combination_id = 0;
        }
        $extradata = ['date' => \Carbon\Carbon::createFromFormat(\App\Context::getContext()->language->date_format_lite, $request->input('date')), 'model_name' => '', 'document_id' => 0, 'document_line_id' => 0, 'combination_id' => $combination_id, 'user_id' => \Auth::id()];
        $stockmovement = $this->stockmovement->create(array_merge($request->all(), $extradata));
        // Stock movement fulfillment (perform stock movements)
        $stockmovement->fulfill();
        return redirect('stockmovements')->with('info', l('This record has been successfully created &#58&#58 (:id) ', ['id' => $stockmovement->id], 'layouts') . $request->get('document_reference') . ' - ' . $request->input('date'));
    }
示例#6
0
 /**
  * Send a request to search for a specified place.
  *
  * @return Response
  */
 public function postScanEvents(scannerRequest $request)
 {
     if ($request->has('save')) {
         $place = Place::where('id', $request->id)->first();
         if (!$place) {
             $place = new Place($request->only(['id', 'place_lat', 'place_lng', 'country', 'state', 'city']));
             $place->save();
             $placeWanted = new PlaceWanted();
             $placeWanted->place_id = $request->id;
             $placeWanted->user_id = \Auth::id();
             $placeWanted->save();
         } else {
             $placeWanted = PlaceWanted::where('user_id', \Auth::id())->where('place_id', $request->id)->first();
             if (!$placeWanted) {
                 $placeWanted = new PlaceWanted();
                 $placeWanted->place_id = $request->id;
                 $placeWanted->user_id = \Auth::id();
                 $placeWanted->save();
             }
         }
     } else {
         $place = Place::where('id', $request->id)->first();
         if (!$place) {
             $place = new Place($request->only(['id', 'place_lat', 'place_lng', 'country', 'state', 'city']));
             $place->save();
         }
     }
     return redirect()->route('scanner', [$request->id]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = User::find($id);
     $permissions = UserPermission::where('user_id', \Auth::id())->lists('package_id')->toArray();
     $packages = Package::orderBy('name')->get();
     return view('permissions.edit', compact('user', 'packages', 'permissions'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateEventRequest $req)
 {
     $input = $req->all();
     // Makes sure chair_id enters database as an integer or null if left empty.
     strcmp($input['chair_id'], "") == 0 ? $input['chair_id'] = null : ($input['chair_id'] = (int) $input['chair_id']);
     // Ensures database times are always in UTC.
     foreach ($input as $key => $value) {
         // Ensures only time fields are changed.
         if (!strpos($key, 'time')) {
             continue;
         }
         // Converts time from PST to UTC.
         $pst = new Carbon($value, 'America/Los_Angeles');
         $utc = $pst->setTimezone('UTC');
         // Sets date/time string back into values for database.
         $input[$key] = $utc->toDateTimeString();
     }
     $input['creator_id'] = \Auth::id();
     // Set creator ID by default
     // Set default close time if needed
     if (!isset($input['close_time'])) {
         $input['close_time'] = $input['start_time'];
     }
     // Set default open time if needed
     if (!isset($input['open_time'])) {
         $input['open_time'] = Carbon::now();
     }
     // Create event
     $event = Event::create($input);
     return redirect()->action('EventsController@show', $event->slug);
 }
示例#9
0
 public function getCreate(Request $request)
 {
     $accounts = \App\Account::where('user_id', '=', \Auth::id())->find($request->id);
     $transactions = new \App\Transaction();
     $categories = ['Deposit/Credit', 'Automobile', 'Groceries', 'Health & Beauty', 'Home Improvement', 'Meals & Entertainment', 'Medical Expense', 'Utilities', 'Insurance', 'Miscellaneous'];
     return view('transaction.create')->with('transactions', $transactions)->with(['categories' => $categories])->with('accounts', $accounts);
 }
 /**
  * Responds to requests to GET /books
  */
 public function getIndex(Request $request)
 {
     // Get all the books "owned" by the current logged in users
     // Sort in descending order by id
     $books = \App\Book::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     return view('books.index')->with('books', $books);
 }
 public function make(Request $request)
 {
     if (!$request->has('title') || !$request->has('description') || !$request->has('noOfPeople') || !$request->has('noOfDays') || !$request->has('budget') || !$request->has('start_date') || !$request->has('end_date')) {
         return view('error')->with('error', 'Please provide all the fields.');
     }
     $task = new \App\Task();
     $input = $request->all();
     $task->employer_id = \Auth::id();
     $task->title = $input['title'];
     $task->description = $input['description'];
     $task->noOfPeople = $input['noOfPeople'];
     $task->noOfDays = $input['noOfDays'];
     $task->budget = $input['budget'];
     $task->start_date = $input['start_date'];
     $task->end_date = $input['end_date'];
     $task->preferred_gender = $input['preferred_gender'];
     $task->workFromHome = $input['workFromHome'];
     if (isset($input['min_age'])) {
         $task->min_age = $input['min_age'];
     }
     if (isset($input['max_age'])) {
         $task->max_age = $input['max_age'];
     }
     $task->save();
     // return response()->json(['success' => $task->id]);
     return redirect('/tasks');
 }
示例#12
0
 /**
  * Responds to requests to POST /landmark/create
  */
 public function postCreate(Request $request)
 {
     if (\App\Landmark::where('name', '=', $request->name)->exists()) {
         \Session::flash('flash_message', 'A Landmark with that name already exists.');
         return redirect('\\landmarks');
     }
     $this->validate($request, ['name' => 'required|min:5', 'description' => 'required|min:1', 'location' => 'required|min:1', 'filepath' => 'required|url', 'photo_description' => 'required|min:1']);
     # Enter landmark and its photo into the database
     $landmark = new \App\Landmark();
     $landmark->name = $request->name;
     $landmark->description = $request->description;
     $landmark->location = $request->location;
     $landmark->user_id = \Auth::id();
     # <--- NEW LINE
     $landmark->save();
     $photo = new \App\Photo();
     $photo->filepath = $request->filepath;
     $photo->photo_description = $request->photo_description;
     $photo->landmark_id = $landmark->id;
     $photo->user_id = \Auth::id();
     $photo->save();
     # Add the tags
     $request->tags;
     if ($request->tags) {
         $tags = $request->tags;
     } else {
         $tags = [];
     }
     $landmark->tags()->sync($tags);
     # Done
     \Session::flash('flash_message', 'Your landmark was added!');
     return redirect('/landmarks');
 }
 /**
  * agreed to buy
  * @param  Request
  * @return [type]
  */
 public function postBuy(Request $request)
 {
     //MENU
     $mainMenu = Category::getParentMenu();
     $allMenu = Category::getAllMenu($mainMenu);
     //HOT PRODUCTS.
     $hotProduct = Product::hotProduct();
     //DISCOUNT PRODUCTS.
     $discountProduct = Product::discountProduct();
     if (\Session::has('giohang')) {
         $data = \Session::get('giohang');
         if ($request->get('account_number') != null) {
             $account_number = $request->get('account_number');
         } else {
             $account_number = null;
         }
         $transaction = ['customer_id' => \Auth::id(), 'ship_id' => \Session::get('ship'), 'pay_id' => \Session::get('pay'), 'amount' => \Session::get('total'), 'message' => $request->get('message'), 'security' => time(), 'account_number' => $request->get('account_number')];
         //dd($transaction);
         $transactions = Transaction::create($transaction);
         //dd($transactions->toArray());
         foreach ($data as $key => $value) {
             $order = ['transaction_id' => $transactions->id, 'product_id' => $value['id'], 'qty' => $value['qty'], 'price_order' => $value['price'], 'discount_order' => $value['discount']];
             $orders = Order::create($order);
         }
         $this->getCancel();
         return view('fornindex.shopping_succeed', compact('allMenu', 'hotProduct', 'discountProduct'));
     }
 }
 /**
  *	delete key registered (Only this seller)
  *	@param	$id 	int|string 	id the virtual product
  *	@param	$res 	Request 	object to validate the type of request, action
  *	@return	json
  */
 public function deleteKey($id, Request $res)
 {
     if (!$res->wantsJson()) {
         return redirect()->back();
     }
     $VirtualProduct = VirtualProduct::find($id);
     if (!count($VirtualProduct->toArray())) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     $product = Product::find($VirtualProduct->product_id);
     if (!count($product->toArray())) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     if ($product->user_id != \Auth::id()) {
         return json_encode(['message' => trans('globals.not_access')]);
     }
     $VirtualProductOrder = VirtualProductOrder::where('virtual_product_id', $VirtualProduct->id)->get();
     if (count($VirtualProductOrder->toArray()) > 0) {
         return json_encode(['message' => trans('product.virtualProductsController_controller.key_been_sold')]);
     }
     $VirtualProduct->status = 'cancelled';
     $VirtualProduct->save();
     $stock = count(VirtualProduct::where('product_id', $product->id)->where('status', 'open')->get()->toArray());
     $product->stock = $stock;
     if ($stock == 0) {
         $product->status = 0;
     }
     $product->save();
     return json_encode(['success' => trans('product.controller.saved_successfully')]);
 }
示例#15
0
 public function editReply($id, EditReplyRequest $request)
 {
     $reply = Reply::findOrFail($id);
     $reply->update(['body' => $request->input('body'), 'editor_id' => \Auth::id(), 'editor_name' => \Auth::user()->name, 'was_edited' => 1, 'edit_reason' => $request->input('edit_reason')]);
     flash()->success('Udało Ci się edytować odpowiedź o ID <b>' . $id . '</b>!');
     return redirect('/forum/topic/' . $request->input('take_topic_id') . '');
 }
 public function markAll()
 {
     $user = User::find(\Auth::id());
     foreach ($user->unreadNotifications as $notification) {
         $notification->markAsRead();
     }
     return redirect()->back();
 }
示例#17
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getProfile()
 {
     // get profile information
     $pets = \App\Pet::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     //return view('profile.index')->with ('pets', $pets);
     //echo ('pets', $pets);
     dump($pets->toArray());
 }
示例#18
0
 /**
  * Responds to requests to
  */
 public function getPage($id = null)
 {
     // update the public_items table and mark the item as bought
     $item = \App\PublicItem::where('id', '=', $id)->find($id);
     //dump($item->toArray());
     $price = null;
     // make sure the item isn't one that is posted by the user
     $user_id = $item['user_id'];
     if ($user_id == \Auth::id()) {
         \Session::flash('flash_message', 'You cannot purchase an item that you posted!');
         // fetch the items from the public_items table
         $items = \App\PublicItem::where('bought', '=', 0)->get();
         //dump($items->toArray());
         $itemsArray = $items->toArray();
         //dump($itemArray->toArray());
         // calculate the tax and total
         return view('pongo.browse_items')->with('items', $itemsArray);
     }
     $price = $item['price'];
     //echo $price;
     $tax = round($price * 0.1, 2);
     //echo $tax;
     $total = $price + $tax;
     //echo $total;
     // update the item as bought
     $item->bought = TRUE;
     $item->save();
     // update the transaction table for the user who buys the product
     $transactionBuy = new \App\Transaction();
     $transactionBuy->transaction_type = "BUY";
     $transactionBuy->public_item_id = $id;
     $transactionBuy->user_id = \Auth::id();
     $transactionBuy->tax = $tax;
     $transactionBuy->total = $total;
     $transactionBuy->save();
     //dump($transactionBuy->toArray());
     $transactionBuyObject = (object) $transactionBuy->toArray();
     $itemAsArray = $item->toArray();
     $itemObject = (object) $itemAsArray;
     // send an email to the user who made the purchase
     \Mail::send(['html' => 'pongo.sales_receipt_email'], array('item' => $itemObject, 'transactionBuy' => $transactionBuyObject), function ($message) {
         $message->to(\Auth::user()->email, \Auth::user()->name)->subject('You made a puchase on Pongo!');
     });
     // update the transaction table for user who sold the product
     $transactionSell = new \App\Transaction();
     $transactionSell->transaction_type = "SELL";
     $transactionSell->public_item_id = $id;
     $transactionSell->user_id = $user_id;
     $transactionSell->tax = $tax;
     $transactionSell->total = $total;
     $transactionSell->save();
     // delete the item from the added_items
     $addedItem = \App\AddedItem::where('one_line_description', '=', $item->one_line_description)->get();
     //dump($publicItem[0]);
     $addedItem[0]->delete();
     \Session::flash('flash_message', 'You successfully purchased the ' . $itemObject->item . '!');
     return view('pongo.receipt_details')->with(['item' => $itemObject, 'transactionBuy' => $transactionBuyObject]);
 }
示例#19
0
 /**
  * Creates a new job
  * @param  ListCreateFormRequest
  * @return [type]
  */
 public function store(JobCreateFormRequest $request)
 {
     $job = new Todojob(array('name' => $request->get('name'), 'description' => $request->get('description')));
     $job->category()->associate(Category::find($request->get('category')));
     $user = User::find(\Auth::id());
     $job = $user->jobs()->save($job);
     Event::fire(new JobWasCreated($job));
     return \Redirect::route('jobs.show', array($job->id))->with('message', 'Your Job has been created!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['message' => 'required|min:2|max:300']);
     $data = $request->all();
     $data['userID'] = \Auth::id();
     $data['parentID'] = $id;
     Message::create(['message' => $data['message'], 'userID' => $data['userID'], 'parentID' => $data['parentID'], 'createdDate' => Carbon::now()]);
     return redirect('message')->with(['flash_message' => 'Your reply has been added!']);
 }
示例#21
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreatePostRequest $req)
 {
     $input = $req->all();
     $input['author_id'] = \Auth::id();
     // Set author ID
     // Create post
     Post::create($input);
     return redirect('/');
 }
 public function store(CreatePlayerRequest $request)
 {
     $formatName = $request->input('name') . '_' . $request->input('surname');
     $getSex = $request->input('sex');
     $getSkin = $request->input('skin');
     \Auth::user()->player()->create(['name' => $formatName, 'age' => $request->input('age'), 'sex' => $getSex, 'skin' => $getSkin, 'from' => $request->input('from'), 'history' => $request->input('history'), 'gid' => \Auth::id()]);
     flash()->success('Udało Ci się utworzyć postać!');
     return redirect('/profile/' . \Auth::id() . '');
 }
示例#23
0
 public function storeAnswer($id, AnswerRequest $request)
 {
     if ($request->input('to_message') == $id) {
         Answer::create(['answer' => $request->input('answer'), 'user_id' => \Auth::id(), 'user_name' => \Auth::user()->name, 'to_message' => $request->input('to_message')]);
         flash()->success('Wiadomość prywatna została wysłana!');
         return redirect('/private/' . $request->input('to_message') . '');
     } else {
         return 'Oszust!';
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $id = $request->input('parentID');
     $questions = Answers::find($id);
     $comment = new Comment();
     $comment->body = $request->input('comment');
     $comment->user_id = Auth::id();
     $questions->comments()->save($comment);
     echo $comment;
 }
示例#25
0
 public function storeCommit($id, CommitRequest $request)
 {
     if ($request->input('to_comment') == $id) {
         \Auth::user()->commit()->create(['body' => $request->input('body'), 'to_comment' => $request->input('to_comment'), 'user_name' => \Auth::user()->name, 'from_user_id' => \Auth::id(), 'to_user_com_id' => $request->input('to_user_com_id')]);
         flash()->success('Dodałeś adnotację do komentarza!');
         return redirect('/profile/' . $request->input('to_user_com_id') . '');
     } else {
         return 'Zastanowię się nad permamentną banicją dla oszustów!';
     }
 }
示例#26
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $userid = \Auth::id();
     $recipe = \App\Recipe::findOrFail($id);
     $starredList = \App\Recipe::whereHas('users', function ($q) use($userid) {
         $q->where('users.id', '=', $userid);
         //echo'here';
     })->get();
     $ingredients = $recipe->ingredients()->get();
     return \View::make('recipes.show')->withRecipe($recipe)->withStarredRecipe($starredList)->withIngredients($ingredients);
 }
示例#27
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     /*
     		$user = \DB::table('users')
     			->select('name', 'email', 'cellphone', 'phoneExt')
     			->where('id', \Auth::id())
     			->first();
     		**/
     $user = User::find(\Auth::id());
     return view('user.show')->with('user', $user);
 }
示例#28
0
 public function getEdit($id = null)
 {
     $address = \App\Address::where('user_id', '=', \Auth::id())->get()->first();
     if (is_null($address)) {
         \Session::flash('flash_message', 'Address not found');
         return redirect('addresses/create');
     }
     $stateModel = new \App\State();
     $states_for_dropdown = $stateModel->getStatesForDropdown();
     return view('address.edit')->with('address', $address)->with(['states_for_dropdown' => $states_for_dropdown]);
 }
示例#29
0
 protected function portalSettings()
 {
     $userId = \Auth::id();
     $userTypeID = \Auth::user()->userTypeId;
     $empType = \DB::table('user_types')->where('id', '=', $userTypeID)->first()->userType;
     $employeeQuery = \DB::table('users')->leftJoin('employees', function ($join) {
         $join->on('employees.userId', '=', 'users.id');
     })->where('users.id', '=', $userId)->first();
     $primaryStore = \DB::table('stores')->where('id', '=', $employeeQuery->primaryStoreId)->first();
     $employeeData = ['name' => $employeeQuery->firstName . ' ' . $employeeQuery->lastName, 'empId' => $employeeQuery->id, 'address1' => $employeeQuery->streetAddress, 'address2' => $employeeQuery->city . ', ' . $employeeQuery->state . ' ' . $employeeQuery->zipcode, 'store' => $primaryStore->location, 'email' => $employeeQuery->email, 'phone' => $employeeQuery->phone, 'username' => $employeeQuery->username, 'rate' => $employeeQuery->hourlyRate, 'type' => $empType];
     return view('portal_settings', $employeeData);
 }
示例#30
0
 public function postPet(Request $request)
 {
     $this->validate($request, ['petName' => 'required', 'breed' => 'required']);
     $pets = new \App\Pet();
     $pets->petName = $request->petName;
     $pets->breed = $request->breed;
     $pets->photo = $request->photo;
     $pets->user_id = \Auth::id();
     $pets->save();
     return redirect('/profile');
     //echo 'posting new pet';
 }