set order

@param string $order_field
@param string $order_type

@return Datatable
4965
public function setOrder($order_field, $order_type)
    {
        $this->order_field = $order_field;
        $this->order_type  = $order_type;
        $this->queryBuilder->orderBy($order_field, $order_type);
        return $this;
    }
725962
public function order($field, $order = null)
    {
        if (!empty($field)) {
            if (is_string($field)) {
                if (!empty($this->options['via'])) {
                    $field = $this->options['via'] . '.' . $field;
                }
                $field = empty($order) ? $field : [$field => $order];
            } elseif (!empty($this->options['via'])) {
                foreach ($field as $key => $val) {
                    if (is_numeric($key)) {
                        $field[$key] = $this->options['via'] . '.' . $val;
                    } else {
                        $field[$this->options['via'] . '.' . $key] = $val;
                        unset($field[$key]);
                    }
                }
            }
            if (!isset($this->options['order'])) {
                $this->options['order'] = [];
            }
            if (is_array($field)) {
                $this->options['order'] = array_merge($this->options['order'], $field);
            } else {
                $this->options['order'][] = $field;
            }
        }
        return $this;
    }
714482
public function setOrderRef($orderRef = '')
    {
        if (settype($orderRef, "string")) {
            if (strlen($orderRef) <= 32) {
                $this->orderRef = $orderRef;

                return true;
            }
            $this->orderRef = null;

            return false;
        }
        $this->orderRef = null;

        return false;
    }
1211957
public function setDescriptor($field, $order = 'ASC')
    {
        // Define Attributes:
        
        $this->setTextField($field);
        $this->setSearchFields([$field]);
        $this->setSortBy([$field => $order]);
        
        // Answer Self:
        
        return $this;
    }
1123713
public function setSession( MShop_Order_Item_Base_Interface $order, $type = '' )
	{
		$context = $this->_getContext();
		$session = $context->getSession();
		$locale = $context->getLocale();
		$currency = $locale->getCurrencyId();
		$language = $locale->getLanguageId();
		$sitecode = $locale->getSite()->getCode();
		$key = 'arcavias/basket/content-' . $sitecode . '-' . $language . '-' . $currency . '-' . strval( $type );

		$session->set( $key, serialize( clone $order ) );
	}
462010
private function applyNestedOrder($relation_name, Builder $query, $relation_field, $value)
    {
        $that = $this;
        return $query->orderBy($relation_name, function ($query) use ($relation_field, $value, $that) {
            $query = $that->applyOrderByClause($query, $relation_field, $value);
        });
    }
831246
public function prepareOrder($order = null, $sort = null)
    {
        if ($order == null or $sort == null) {
            $this->setOrderBy = '';

            return $this;
        }

        if (!in_array($sort, ['ASC', 'DESC'])) {
            $sort = 'DESC';
        }

        $this->setOrderBy = ' ORDER BY ' . $order . ' ' . $sort;

        return $this;
    }
270072
public function set_sortorder($sortorder) {
        $oldorder = $this->file_record->sortorder;
        $filerecord = new stdClass;
        $filerecord->sortorder = $sortorder;
        $this->update($filerecord);
        if (!$this->is_directory()) {
            // Callback for file sort order change.
            if ($pluginsfunction = get_plugins_with_function('after_file_sorted')) {
                foreach ($pluginsfunction as $plugintype => $plugins) {
                    foreach ($plugins as $pluginfunction) {
                        $pluginfunction($this->file_record, $oldorder, $sortorder);
                    }
                }
            }
        }
    }
1214027
public function byFieldValue(
        string $field,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FIELD,
            'field' => Item::getPathByField($field),
            'order' => $order,
        ];

        return $this;
    }
825580
def set_sort_order(self, sort_order):
        

        if not isinstance(sort_order, SortOrder):
            raise DaftException("sort_order should be an instance of SortOrder.")

        self._sort_order = str(sort_order)
715873
public function setOrder($order)
    {
        if (! is_array($order)) {
            $order = func_get_args();
        }

        $this->order = $order;

        return $this;
    }
1349285
public static function placeOrders($type_order)
    {
        $cart = self::ofType($type_order)
            ->where('user_id', Auth::user()->id)
            ->orderBy('id', 'desc')
            ->first();

        $show_order_route = 'orders.show_cart';

        $cartDetail = OrderDetail::where('order_id', $cart->id)->get();

        $address_id = 0;

        //When address is invalid, it is because it comes from the creation of a free product. You must have a user direction (Default)
        if (is_null($cart->address_id)) {
            $useraddress = Address::auth()->orderBy('default', 'DESC')->first();
            if ($useraddress) {
                $address_id = $useraddress->address_id;
            } else {
                return trans('address.no_registered');
            }
        } else {
            $address_id = $cart->address_id;
        }

        $address = Address::where('id', $address_id)->first();

        //Checks if the user has points for the cart price and the store has stock
        //and set the order prices to the current ones if different
        //Creates the lists or sellers to send mail to
        $total_points = 0;
        $seller_email = [];
        foreach ($cartDetail as $orderDetail) {
            $product = Product::find($orderDetail->product_id);
            $seller = User::find($product->updated_by);

            // dd($product, $seller);

            if (!in_array($seller->email, $seller_email)) {
                $seller_email[] = $seller->email;
            }
            $total_points += $orderDetail->quantity * $product->price;
            if ($orderDetail->price != $product->price) {
                $orderDetail->price = $product->price;
                $orderDetail->save();
            }

            if ($product->stock < $orderDetail->quantity) {
                return trans('store.insufficientStock');
            }
        }

        //Checks if the user has points for the cart price
        $user = Auth::user();
        if ($user->current_points < $total_points && config('app.payment_method') == 'Points') {
            return trans('store.cart_view.insufficient_funds');
        }

        if (config('app.payment_method') == 'Points') {
            $negativeTotal = -1 * $total_points;
            //7 is the action type id for order checkout
            // $pointsModified = $user->modifyPoints($negativeTotal, 7, $cart->id);
            // while refactoring
        } else {
            $pointsModified = true;
        }

        if ($pointsModified) {
            //Separate the order for each seller
            //Looks for all the different sellers in the cart
            $sellers = [];
            foreach ($cartDetail as $orderDetail) {
                if (!in_array($orderDetail->product->updated_by, $sellers)) {
                    $sellers[] = $orderDetail->product->updated_by;
                }
            }
            foreach ($sellers as $seller) {
                //Creates a new order and address for each seller
                $newOrder = new self();
                $newOrder->user_id = $user->id;
                $newOrder->address_id = $address->id;
                $newOrder->status = ($type_order == 'freeproduct') ? 'paid' : 'open';
                $newOrder->type = ($type_order == 'freeproduct') ? 'freeproduct' : 'order';
                $newOrder->seller_id = $seller;
                $newOrder->save();

                $newOrder->seller->notify(new OrderWasUpdated($newOrder));

                //moves the details to the new orders
                foreach ($cartDetail as $orderDetail) {
                    if ($orderDetail->product->updated_by == $seller) {
                        $orderDetail->order_id = $newOrder->id;
                        $orderDetail->save();
                    }

                    //Increasing product counters.
                    (new ProductsRepository)->increment('sale_counts', $orderDetail->product);

                    //saving tags in users preferences
                    if (trim($orderDetail->product->tags) != '' && auth()->check()) {
                        auth()->user()->updatePreferences('product_purchased', $product->tags);
                    }
                }
            }

            //Changes the stock of each product in the order
            foreach ($cartDetail as $orderDetail) {
                $product = Product::find($orderDetail->product_id);
                $product->stock = $product->stock - $orderDetail->quantity;
                $product->save();
            }
            foreach ($seller_email as $email) {
                $mailed_order = self::where('id', $newOrder->id)->with('details')->get()->first();

                //Send a mail to the user: Order has been placed
                $data = [
                    'orderId' => $newOrder->id,
                    'order'   => $mailed_order,
                ];
                //dd($data['order']->details,$newOrder->id);
                $title = trans('email.new_order_for_user.subject')." (#$newOrder->id)";
                Mail::send('emails.neworder', compact('data', 'title'), function ($message) use ($user) {
                    $message->to($user->email)->subject(trans('email.new_order_for_user.subject'));
                });
                //Send a mail to the seller: Order has been placed
                $title = trans('email.new_order_for_seller.subject')." (#$newOrder->id)";
                Mail::send('emails.sellerorder', compact('data', 'title'), function ($message) use ($email) {
                    $message->to($email)->subject(trans('email.new_order_for_seller.subject'));
                });
            }

            return;
        } else {
            return trans('store.insufficientFunds');
        }
    }
1188260
public function setOrder($order)
    {
        $this->_order = $order;
        $this->_state->order = $order;

        return $this;
    }
153223
public function order($field, $order = 'desc')
    {
        $field = $this->model->field($field);
        $order = $this->normalizeOrder($order);

        $this->builder->addOrderBy($this->connection->quoteIdentifier($field->mappedName()), $order);

        return $this;
    }
1241837
protected function setOrderCheckoutComplete($order_id)
    {
        $this->data_order = $this->order->get($order_id);

        if (empty($this->data_order)) {
            $this->outputHttpStatus(404);
        }

        $this->prepareOrderCheckoutComplete($this->data_order);
    }
487158
public function order($order, $type = 'DESC')
    {

        $this->string['order'] .= $this->useBuilder('order')
            ->order($order, $type);

        return $this;
    }
611855
public function orderBy(string $column, string $type = null)
    {
        if ($type) {
            $type = strtoupper($type);

            if (!in_array($type, ['ASC', 'DESC'])) {
                throw new SqlException('Wrong ORDER type for statement.');
            }
        }

        $this->addOrderBy($this->dialect()->quoteName($column), $type);

        return $this;
    }