当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::id方法代码示例

本文整理汇总了PHP中App\Http\Controllers\Auth::id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::id方法的具体用法?PHP Auth::id怎么用?PHP Auth::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\Auth的用法示例。


在下文中一共展示了Auth::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: destroy

 /**
  * 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');
 }
开发者ID:anhtt93,项目名称:BookStore,代码行数:14,代码来源:TaskController.php

示例2: getPage

 /**
  * 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);
 }
开发者ID:rhsu0268,项目名称:Pongo,代码行数:33,代码来源:BrowseItemsController.php

示例3: destroy

 /**
  * 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');
 }
开发者ID:anhtt93,项目名称:BookStore,代码行数:14,代码来源:OrderController.php

示例4: mrbs

 public function mrbs()
 {
     $user = User::find(\Auth::id());
     $userName = $user->name;
     $passwd = $user->password;
     return view('mrbs.mrbs')->with('userName', $userName)->with('passwd', $passwd);
 }
开发者ID:a5526000,项目名称:LIMS,代码行数:7,代码来源:HomeController.php

示例5: store

    /**
     * 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'));
    }
开发者ID:rogerapras,项目名称:aBillander,代码行数:35,代码来源:StockMovementsController.php

示例6: postScanEvents

 /**
  * 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]);
 }
开发者ID:charlieboo,项目名称:creatrip,代码行数:34,代码来源:HomeController.php

示例7: edit

 /**
  * 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'));
 }
开发者ID:hannahtinkler,项目名称:too-tool-for-school,代码行数:13,代码来源:UserPermissionsController.php

示例8: store

 /**
  * 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);
 }
开发者ID:natalieduong,项目名称:konnection,代码行数:36,代码来源:EventsController.php

示例9: getCreate

 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);
 }
开发者ID:trietvu,项目名称:p4,代码行数:7,代码来源:TransactionController.php

示例10: getIndex

 /**
  * 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);
 }
开发者ID:jpedroza,项目名称:laravelvideobooks.aacax.net,代码行数:10,代码来源:BookController.php

示例11: make

 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');
 }
开发者ID:simmimourya1,项目名称:Ruralfuse_final,代码行数:27,代码来源:TaskController.php

示例12: postCreate

 /**
  * 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');
 }
开发者ID:emersonFang,项目名称:p4,代码行数:36,代码来源:LandmarkController.php

示例13: postBuy

 /**
  * 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'));
     }
 }
开发者ID:hoangvu2015,项目名称:laravel_totnghiep,代码行数:33,代码来源:CartController.php

示例14: deleteKey

 /**
  *	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')]);
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:36,代码来源:VirtualProductsController.php

示例15: editReply

 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') . '');
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:7,代码来源:TopicController.php


注:本文中的App\Http\Controllers\Auth::id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。