code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
protected function writeNotExists(Where $where, array &$whereArray)
{
$whereArray = \array_merge(
$whereArray,
$this->writeExistence($where, 'getNotExists', 'NOT EXISTS')
);
} | @param Where $where
@param array $whereArray
@return array | writeNotExists | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/WhereWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/WhereWriter.php | MIT |
protected function writeSubWheres(Where $where, array &$whereArray)
{
$subWheres = $where->getSubWheres();
\array_walk(
$subWheres,
function (&$subWhere) {
$subWhere = "({$this->writeWhere($subWhere)})";
}
);
$whereArray = \array_merge($whereArray, $subWheres);
} | @param Where $where
@param array $whereArray
@return array | writeSubWheres | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/WhereWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/WhereWriter.php | MIT |
public function __construct(GenericBuilder $writer, PlaceholderWriter $placeholder)
{
$this->writer = $writer;
$this->placeholderWriter = $placeholder;
} | @param GenericBuilder $writer
@param PlaceholderWriter $placeholder | __construct | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/DeleteWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/DeleteWriter.php | MIT |
public function write(Delete $delete)
{
$table = $this->writer->writeTable($delete->getTable());
$parts = array("DELETE FROM {$table}");
AbstractBaseWriter::writeWhereCondition($delete, $this->writer, $this->placeholderWriter, $parts);
AbstractBaseWriter::writeLimitCondition($delete, $this->placeholderWriter, $parts);
$comment = AbstractBaseWriter::writeQueryComment($delete);
return $comment.implode(' ', $parts);
} | @param Delete $delete
@return string | write | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/DeleteWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/DeleteWriter.php | MIT |
public function __construct(GenericBuilder $writer)
{
$this->writer = $writer;
} | @param GenericBuilder $writer | __construct | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/AbstractSetWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/AbstractSetWriter.php | MIT |
public function __construct(GenericBuilder $writer, PlaceholderWriter $placeholderWriter)
{
$this->writer = $writer;
$this->placeholderWriter = $placeholderWriter;
} | @param GenericBuilder $writer
@param PlaceholderWriter $placeholderWriter | __construct | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/ColumnWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/ColumnWriter.php | MIT |
public function writeSelectsAsColumns(Select $select)
{
$selectAsColumns = $select->getColumnSelects();
if (!empty($selectAsColumns)) {
$selectWriter = WriterFactory::createSelectWriter($this->writer, $this->placeholderWriter);
$selectAsColumns = $this->selectColumnToQuery($selectAsColumns, $selectWriter);
}
return $selectAsColumns;
} | @param Select $select
@return array | writeSelectsAsColumns | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/ColumnWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/ColumnWriter.php | MIT |
public function writeColumnWithAlias(Column $column)
{
if (($alias = $column->getAlias()) && !$column->isAll()) {
return $this->writeColumn($column).' AS '.$this->writer->writeColumnAlias($alias);
}
return $this->writeColumn($column);
} | @param Column $column
@return string | writeColumnWithAlias | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/ColumnWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/ColumnWriter.php | MIT |
public function writeColumn(Column $column)
{
$alias = $column->getTable()->getAlias();
$table = ($alias) ? $this->writer->writeTableAlias($alias) : $this->writer->writeTable($column->getTable());
$columnString = (empty($table)) ? '' : "{$table}.";
$columnString .= $this->writer->writeColumnName($column);
return $columnString;
} | @param Column $column
@return string | writeColumn | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/ColumnWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/ColumnWriter.php | MIT |
public function __construct(GenericBuilder $writer)
{
$this->writer = $writer;
} | @param GenericBuilder $writer | __construct | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/MinusWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/MinusWriter.php | MIT |
public function write(Minus $minus)
{
$first = $this->writer->write($minus->getFirst());
$second = $this->writer->write($minus->getSecond());
return $first."\n".Minus::MINUS."\n".$second;
} | @param Minus $minus
@return string | write | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/MinusWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/MinusWriter.php | MIT |
public function get()
{
return $this->placeholders;
} | @return array | get | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
public function reset()
{
$this->counter = 1;
$this->placeholders = [];
return $this;
} | @return $this | reset | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
public function add($value)
{
$placeholderKey = ':v'.$this->counter;
$this->placeholders[$placeholderKey] = $this->setValidSqlValue($value);
++$this->counter;
return $placeholderKey;
} | @param $value
@return string | add | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function setValidSqlValue($value)
{
$value = $this->writeNullSqlString($value);
$value = $this->writeStringAsSqlString($value);
$value = $this->writeBooleanSqlString($value);
return $value;
} | @param $value
@return string | setValidSqlValue | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function writeNullSqlString($value)
{
if (\is_null($value) || (\is_string($value) && empty($value))) {
$value = $this->writeNull();
}
return $value;
} | @param $value
@return string | writeNullSqlString | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function writeNull()
{
return 'NULL';
} | @return string | writeNull | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function writeStringAsSqlString($value)
{
if (\is_string($value)) {
$value = $this->writeString($value);
}
return $value;
} | @param string $value
@return string | writeStringAsSqlString | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function writeString($value)
{
return $value;
} | @param string $value
@return string | writeString | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function writeBooleanSqlString($value)
{
if (\is_bool($value)) {
$value = $this->writeBoolean($value);
}
return $value;
} | @param string $value
@return string | writeBooleanSqlString | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
protected function writeBoolean($value)
{
$value = \filter_var($value, FILTER_VALIDATE_BOOLEAN);
return ($value) ? '1' : '0';
} | @param bool $value
@return string | writeBoolean | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/PlaceholderWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/PlaceholderWriter.php | MIT |
public function write(UnionAll $unionAll)
{
return $this->abstractWrite($unionAll, 'getUnions', UnionAll::UNION_ALL);
} | @param UnionAll $unionAll
@return string | write | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/UnionAllWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/UnionAllWriter.php | MIT |
public function write(Update $update)
{
$values = $update->getValues();
if (empty($values)) {
throw new QueryException('No values to update in Update query.');
}
$parts = array(
'UPDATE '.$this->writer->writeTable($update->getTable()).' SET ',
$this->writeUpdateValues($update),
);
AbstractBaseWriter::writeWhereCondition($update, $this->writer, $this->placeholderWriter, $parts);
AbstractBaseWriter::writeLimitCondition($update, $this->placeholderWriter, $parts);
$comment = AbstractBaseWriter::writeQueryComment($update);
return $comment.implode(' ', $parts);
} | @param Update $update
@throws QueryException
@return string | write | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/UpdateWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/UpdateWriter.php | MIT |
public function __construct(GenericBuilder $writer, PlaceholderWriter $placeholder)
{
$this->writer = $writer;
$this->placeholderWriter = $placeholder;
$this->columnWriter = WriterFactory::createColumnWriter($writer, $placeholder);
} | @param GenericBuilder $writer
@param PlaceholderWriter $placeholder | __construct | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/AbstractBaseWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/AbstractBaseWriter.php | MIT |
public static function writeQueryComment(AbstractBaseQuery $class)
{
$comment = '';
if ('' !== $class->getComment()) {
$comment = $class->getComment();
}
return $comment;
} | @param AbstractBaseQuery $class
@return string | writeQueryComment | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/AbstractBaseWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/AbstractBaseWriter.php | MIT |
public static function writeWhereCondition(
AbstractBaseQuery $class,
$writer, PlaceholderWriter
$placeholderWriter,
array &$parts
) {
if (!is_null($class->getWhere())) {
$whereWriter = WriterFactory::createWhereWriter($writer, $placeholderWriter);
$parts[] = "WHERE {$whereWriter->writeWhere($class->getWhere())}";
}
} | @param AbstractBaseQuery $class
@param GenericBuilder $writer
@param PlaceholderWriter $placeholderWriter
@param array $parts | writeWhereCondition | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/AbstractBaseWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/AbstractBaseWriter.php | MIT |
public static function writeLimitCondition(
AbstractBaseQuery $class,
PlaceholderWriter $placeholderWriter,
array &$parts
) {
if (!is_null($class->getLimitStart())) {
$start = $placeholderWriter->add($class->getLimitStart());
$parts[] = "LIMIT {$start}";
}
} | @param AbstractBaseQuery $class
@param PlaceholderWriter $placeholderWriter
@param array $parts | writeLimitCondition | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/AbstractBaseWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/AbstractBaseWriter.php | MIT |
public function __construct(GenericBuilder $writer, PlaceholderWriter $placeholder)
{
$this->writer = $writer;
$this->columnWriter = WriterFactory::createColumnWriter($this->writer, $placeholder);
} | @param GenericBuilder $writer
@param PlaceholderWriter $placeholder | __construct | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/InsertWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/InsertWriter.php | MIT |
public function write(Insert $insert)
{
$columns = $insert->getColumns();
if (empty($columns)) {
throw new QueryException('No columns were defined for the current schema.');
}
$columns = $this->writeQueryColumns($columns);
$values = $this->writeQueryValues($insert->getValues());
$table = $this->writer->writeTable($insert->getTable());
$comment = AbstractBaseWriter::writeQueryComment($insert);
return $comment."INSERT INTO {$table} ($columns) VALUES ($values)";
} | @param Insert $insert
@throws QueryException
@return string | write | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/InsertWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/InsertWriter.php | MIT |
protected function writeQueryColumns($columns)
{
return $this->writeCommaSeparatedValues($columns, $this->columnWriter, 'writeColumn');
} | @param $columns
@return string | writeQueryColumns | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/InsertWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/InsertWriter.php | MIT |
protected function writeQueryValues($values)
{
return $this->writeCommaSeparatedValues($values, $this->writer, 'writePlaceholderValue');
} | @param $values
@return string | writeQueryValues | php | nilportugues/php-sql-query-builder | src/Builder/Syntax/InsertWriter.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/src/Builder/Syntax/InsertWriter.php | MIT |
public function partName()
{
return 'DUMMY';
} | @return string | partName | php | nilportugues/php-sql-query-builder | tests/Manipulation/Resources/DummyQuery.php | https://github.com/nilportugues/php-sql-query-builder/blob/master/tests/Manipulation/Resources/DummyQuery.php | MIT |
public function boot()
{
$this->registerLogger();
$this->registerRoutes();
$this->registerResources();
$this->registerPublishing();
$this->registerCommands();
Stripe::setAppInfo(
'Laravel Cashier',
Cashier::VERSION,
'https://laravel.com'
);
} | Bootstrap any package services.
@return void | boot | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
public function register()
{
$this->configure();
$this->bindLogger();
$this->bindInvoiceRenderer();
} | Register any application services.
@return void | register | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function configure()
{
$this->mergeConfigFrom(
__DIR__.'/../config/cashier.php', 'cashier'
);
} | Setup the configuration for Cashier.
@return void | configure | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function bindLogger()
{
$this->app->bind(LoggerInterface::class, function ($app) {
return new Logger(
$app->make('log')->channel(config('cashier.logger'))
);
});
} | Bind the Stripe logger interface to the Cashier logger.
@return void | bindLogger | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function bindInvoiceRenderer()
{
$this->app->bind(InvoiceRenderer::class, function ($app) {
return $app->make(config('cashier.invoices.renderer', DompdfInvoiceRenderer::class));
});
} | Bind the default invoice renderer.
@return void | bindInvoiceRenderer | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function registerLogger()
{
if (config('cashier.logger')) {
Stripe::setLogger($this->app->make(LoggerInterface::class));
}
} | Register the Stripe logger.
@return void | registerLogger | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function registerRoutes()
{
if (Cashier::$registersRoutes) {
Route::group([
'prefix' => config('cashier.path'),
'namespace' => 'Laravel\Cashier\Http\Controllers',
'as' => 'cashier.',
], function () {
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
});
}
} | Register the package routes.
@return void | registerRoutes | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function registerResources()
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'cashier');
} | Register the package resources.
@return void | registerResources | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function registerPublishing()
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/cashier.php' => $this->app->configPath('cashier.php'),
], 'cashier-config');
$publishesMigrationsMethod = method_exists($this, 'publishesMigrations')
? 'publishesMigrations'
: 'publishes';
$this->{$publishesMigrationsMethod}([
__DIR__.'/../database/migrations' => $this->app->databasePath('migrations'),
], 'cashier-migrations');
$this->publishes([
__DIR__.'/../resources/views' => $this->app->resourcePath('views/vendor/cashier'),
], 'cashier-views');
}
} | Register the package's publishable resources.
@return void | registerPublishing | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
protected function registerCommands()
{
if ($this->app->runningInConsole()) {
$this->commands([
WebhookCommand::class,
]);
}
} | Register the package's commands.
@return void | registerCommands | php | laravel/cashier-stripe | src/CashierServiceProvider.php | https://github.com/laravel/cashier-stripe/blob/master/src/CashierServiceProvider.php | MIT |
public function __construct($owner, Session $session)
{
$this->owner = $owner;
$this->session = $session;
} | Create a new checkout session instance.
@param \Illuminate\Database\Eloquent\Model|null $owner
@param \Stripe\Checkout\Session $session
@return void | __construct | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public static function guest()
{
return new CheckoutBuilder();
} | Begin a new guest checkout session.
@return \Laravel\Cashier\CheckoutBuilder | guest | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public static function customer($owner, $parentInstance = null)
{
return new CheckoutBuilder($owner, $parentInstance);
} | Begin a new customer checkout session.
@param \Illuminate\Database\Eloquent\Model $owner
@param object|null $parentInstance
@return \Laravel\Cashier\CheckoutBuilder | customer | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public static function create($owner, array $sessionOptions = [], array $customerOptions = [])
{
$data = array_merge([
'mode' => Session::MODE_PAYMENT,
], $sessionOptions);
if ($owner) {
$data['customer'] = $owner->createOrGetStripeCustomer($customerOptions)->id;
$stripe = $owner->stripe();
} else {
$stripe = Cashier::stripe();
}
// Make sure to collect address and name when Tax ID collection is enabled...
if (isset($data['customer']) && ($data['tax_id_collection']['enabled'] ?? false)) {
$data['customer_update']['address'] = 'auto';
$data['customer_update']['name'] = 'auto';
}
if ($data['mode'] === Session::MODE_PAYMENT && ($data['invoice_creation']['enabled'] ?? false)) {
$data['invoice_creation']['invoice_data']['metadata']['is_on_session_checkout'] = true;
} elseif ($data['mode'] === Session::MODE_SUBSCRIPTION) {
$data['subscription_data']['metadata']['is_on_session_checkout'] = true;
}
// Remove success and cancel URLs if "ui_mode" is "embedded"...
if (isset($data['ui_mode']) && $data['ui_mode'] === 'embedded') {
$data['return_url'] = $sessionOptions['return_url'] ?? route('home');
// Remove return URL for embedded UI mode when no redirection is desired on completion...
if (isset($data['redirect_on_completion']) && $data['redirect_on_completion'] === 'never') {
unset($data['return_url']);
}
} else {
$data['success_url'] = $sessionOptions['success_url'] ?? route('home').'?checkout=success';
$data['cancel_url'] = $sessionOptions['cancel_url'] ?? route('home').'?checkout=cancelled';
}
$session = $stripe->checkout->sessions->create($data);
return new static($owner, $session);
} | Begin a new checkout session.
@param \Illuminate\Database\Eloquent\Model|null $owner
@param array $sessionOptions
@param array $customerOptions
@return \Laravel\Cashier\Checkout | create | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function redirect()
{
return Redirect::to($this->session->url, 303);
} | Redirect to the checkout session.
@return \Illuminate\Http\RedirectResponse | redirect | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function toResponse($request)
{
return $this->redirect();
} | Create an HTTP response that represents the object.
@param \Illuminate\Http\Request $request
@return \Symfony\Component\HttpFoundation\Response | toResponse | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function asStripeCheckoutSession()
{
return $this->session;
} | Get the Checkout Session as a Stripe Checkout Session object.
@return \Stripe\Checkout\Session | asStripeCheckoutSession | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function toArray()
{
return $this->asStripeCheckoutSession()->toArray();
} | Get the instance as an array.
@return array | toArray | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function toJson($options = 0)
{
return json_encode($this->jsonSerialize(), $options);
} | Convert the object to its JSON representation.
@param int $options
@return string | toJson | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function jsonSerialize()
{
return $this->toArray();
} | [\ReturnTypeWillChange] | jsonSerialize | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function __get($key)
{
return $this->session->{$key};
} | Dynamically get values from the Stripe object.
@param string $key
@return mixed | __get | php | laravel/cashier-stripe | src/Checkout.php | https://github.com/laravel/cashier-stripe/blob/master/src/Checkout.php | MIT |
public function __construct($owner, StripePaymentMethod $paymentMethod)
{
if (is_null($paymentMethod->customer)) {
throw new LogicException('The payment method is not attached to a customer.');
}
if ($owner->stripe_id !== $paymentMethod->customer) {
throw InvalidPaymentMethod::invalidOwner($paymentMethod, $owner);
}
$this->owner = $owner;
$this->paymentMethod = $paymentMethod;
} | Create a new PaymentMethod instance.
@param \Illuminate\Database\Eloquent\Model $owner
@param \Stripe\PaymentMethod $paymentMethod
@return void
@throws \Laravel\Cashier\Exceptions\InvalidPaymentMethod | __construct | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function delete()
{
$this->owner->deletePaymentMethod($this->paymentMethod);
} | Delete the payment method.
@return void | delete | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function owner()
{
return $this->owner;
} | Get the Stripe model instance.
@return \Illuminate\Database\Eloquent\Model | owner | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function asStripePaymentMethod()
{
return $this->paymentMethod;
} | Get the Stripe PaymentMethod instance.
@return \Stripe\PaymentMethod | asStripePaymentMethod | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function toArray()
{
return $this->asStripePaymentMethod()->toArray();
} | Get the instance as an array.
@return array | toArray | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function toJson($options = 0)
{
return json_encode($this->jsonSerialize(), $options);
} | Convert the object to its JSON representation.
@param int $options
@return string | toJson | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function jsonSerialize()
{
return $this->toArray();
} | [\ReturnTypeWillChange] | jsonSerialize | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function __get($key)
{
return $this->paymentMethod->{$key};
} | Dynamically get values from the Stripe object.
@param string $key
@return mixed | __get | php | laravel/cashier-stripe | src/PaymentMethod.php | https://github.com/laravel/cashier-stripe/blob/master/src/PaymentMethod.php | MIT |
public function meteredPrice($price)
{
return $this->price($price, null);
} | Set a metered price on the subscription builder.
@param string $price
@return $this | meteredPrice | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function quantity($quantity, $price = null)
{
if (is_null($price)) {
if (count($this->items) > 1) {
throw new InvalidArgumentException('Price is required when creating subscriptions with multiple prices.');
}
$price = Arr::first($this->items)['price'];
}
return $this->price($price, $quantity);
} | Specify the quantity of a subscription item.
@param int|null $quantity
@param string|null $price
@return $this | quantity | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function trialDays($trialDays)
{
$this->trialExpires = Carbon::now()->addDays($trialDays);
return $this;
} | Specify the number of days of the trial.
@param int $trialDays
@return $this | trialDays | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function trialUntil($trialUntil)
{
$this->trialExpires = $trialUntil;
return $this;
} | Specify the ending date of the trial.
@param \Carbon\Carbon|\Carbon\CarbonInterface $trialUntil
@return $this | trialUntil | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function skipTrial()
{
$this->skipTrial = true;
return $this;
} | Force the trial to end immediately.
@return $this | skipTrial | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function anchorBillingCycleOn($date)
{
if ($date instanceof DateTimeInterface) {
$date = $date->getTimestamp();
}
$this->billingCycleAnchor = $date;
return $this;
} | Change the billing cycle anchor on a subscription creation.
@param \DateTimeInterface|int $date
@return $this | anchorBillingCycleOn | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function withMetadata($metadata)
{
$this->metadata = (array) $metadata;
return $this;
} | The metadata to apply to a new subscription.
@param array $metadata
@return $this | withMetadata | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function add(array $customerOptions = [], array $subscriptionOptions = [])
{
return $this->create(null, $customerOptions, $subscriptionOptions);
} | Add a new Stripe subscription to the Stripe model.
@param array $customerOptions
@param array $subscriptionOptions
@return \Laravel\Cashier\Subscription
@throws \Laravel\Cashier\Exceptions\IncompletePayment | add | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function create($paymentMethod = null, array $customerOptions = [], array $subscriptionOptions = [])
{
if (empty($this->items)) {
throw new Exception('At least one price is required when starting subscriptions.');
}
$stripeCustomer = $this->getStripeCustomer($paymentMethod, $customerOptions);
$stripeSubscription = $this->owner->stripe()->subscriptions->create(array_merge(
['customer' => $stripeCustomer->id],
$this->buildPayload(),
$subscriptionOptions
));
$subscription = $this->createSubscription($stripeSubscription);
$this->handlePaymentFailure($subscription, $paymentMethod);
return $subscription;
} | Create a new Stripe subscription.
@param \Stripe\PaymentMethod|string|null $paymentMethod
@param array $customerOptions
@param array $subscriptionOptions
@return \Laravel\Cashier\Subscription
@throws \Exception
@throws \Laravel\Cashier\Exceptions\IncompletePayment | create | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function createAndSendInvoice(array $customerOptions = [], array $subscriptionOptions = [])
{
return $this->create(null, $customerOptions, array_merge([
'days_until_due' => 30,
], $subscriptionOptions, [
'collection_method' => 'send_invoice',
]));
} | Create a new Stripe subscription and send an invoice to the customer.
@param array $customerOptions
@param array $subscriptionOptions
@return \Laravel\Cashier\Subscription
@throws \Exception
@throws \Laravel\Cashier\Exceptions\IncompletePayment | createAndSendInvoice | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function checkout(array $sessionOptions = [], array $customerOptions = [])
{
if (empty($this->items)) {
throw new Exception('At least one price is required when starting subscriptions.');
}
if (! $this->skipTrial && $this->trialExpires) {
// Checkout Sessions are active for 24 hours after their creation and within that time frame the customer
// can complete the payment at any time. Stripe requires the trial end at least 48 hours in the future
// so that there is still at least a one day trial if your customer pays at the end of the 24 hours.
// We also add 10 seconds of extra time to account for any delay with an API request onto Stripe.
$minimumTrialPeriod = Carbon::now()->addHours(48)->addSeconds(10);
$trialEnd = $this->trialExpires->gt($minimumTrialPeriod) ? $this->trialExpires : $minimumTrialPeriod;
} else {
$trialEnd = null;
}
$billingCycleAnchor = $trialEnd === null ? $this->billingCycleAnchor : null;
$payload = array_filter([
'line_items' => Collection::make($this->items)->values()->all(),
'mode' => 'subscription',
'subscription_data' => array_filter([
'default_tax_rates' => $this->getTaxRatesForPayload(),
'trial_end' => $trialEnd ? $trialEnd->getTimestamp() : null,
'billing_cycle_anchor' => $billingCycleAnchor,
'proration_behavior' => $billingCycleAnchor ? $this->prorateBehavior() : null,
'metadata' => array_merge($this->metadata, [
'name' => $this->type,
'type' => $this->type,
]),
]),
]);
return Checkout::customer($this->owner, $this)
->create([], array_merge_recursive($payload, $sessionOptions), $customerOptions);
} | Begin a new Checkout Session.
@param array $sessionOptions
@param array $customerOptions
@return \Laravel\Cashier\Checkout | checkout | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
protected function getStripeCustomer($paymentMethod = null, array $options = [])
{
$customer = $this->owner->createOrGetStripeCustomer($options);
if ($paymentMethod) {
$this->owner->updateDefaultPaymentMethod($paymentMethod);
}
return $customer;
} | Get the Stripe customer instance for the current user and payment method.
@param \Stripe\PaymentMethod|string|null $paymentMethod
@param array $options
@return \Stripe\Customer | getStripeCustomer | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
protected function buildPayload()
{
$payload = array_filter([
'automatic_tax' => $this->automaticTaxPayload(),
'billing_cycle_anchor' => $this->billingCycleAnchor,
'coupon' => $this->couponId,
'expand' => ['latest_invoice.payment_intent'],
'metadata' => $this->metadata,
'items' => Collection::make($this->items)->values()->all(),
'payment_behavior' => $this->paymentBehavior(),
'promotion_code' => $this->promotionCodeId,
'proration_behavior' => $this->prorateBehavior(),
'trial_end' => $this->getTrialEndForPayload(),
'off_session' => true,
]);
if ($taxRates = $this->getTaxRatesForPayload()) {
$payload['default_tax_rates'] = $taxRates;
}
return $payload;
} | Build the payload for subscription creation.
@return array | buildPayload | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
protected function getTrialEndForPayload()
{
if ($this->skipTrial) {
return 'now';
}
if ($this->trialExpires) {
return $this->trialExpires->getTimestamp();
}
} | Get the trial ending date for the Stripe payload.
@return int|string|null | getTrialEndForPayload | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
protected function getTaxRatesForPayload()
{
if ($taxRates = $this->owner->taxRates()) {
return $taxRates;
}
} | Get the tax rates for the Stripe payload.
@return array|null | getTaxRatesForPayload | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
protected function getPriceTaxRatesForPayload($price)
{
if ($taxRates = $this->owner->priceTaxRates()) {
return $taxRates[$price] ?? null;
}
} | Get the price tax rates for the Stripe payload.
@param string $price
@return array|null | getPriceTaxRatesForPayload | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function getItems()
{
return $this->items;
} | Get the items set on the subscription builder.
@return array | getItems | php | laravel/cashier-stripe | src/SubscriptionBuilder.php | https://github.com/laravel/cashier-stripe/blob/master/src/SubscriptionBuilder.php | MIT |
public function __construct($owner, StripeInvoice $invoice, array $refreshData = [])
{
if ($owner->stripe_id !== $invoice->customer) {
throw InvalidInvoice::invalidOwner($invoice, $owner);
}
$this->owner = $owner;
$this->invoice = $invoice;
$this->refreshData = $refreshData;
} | Create a new invoice instance.
@param \Illuminate\Database\Eloquent\Model $owner
@param \Stripe\Invoice $invoice
@param array $refreshData
@return void
@throws \Laravel\Cashier\Exceptions\InvalidInvoice | __construct | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function date($timezone = null)
{
$carbon = Carbon::createFromTimestampUTC($this->invoice->created);
return $timezone ? $carbon->setTimezone($timezone) : $carbon;
} | Get a Carbon instance for the invoicing date.
@param \DateTimeZone|string $timezone
@return \Carbon\Carbon | date | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function dueDate($timezone = null)
{
if ($this->invoice->due_date) {
$carbon = Carbon::createFromTimestampUTC($this->invoice->due_date);
return $timezone ? $carbon->setTimezone($timezone) : $carbon;
}
} | Get a Carbon instance for the invoice's due date.
@param \DateTimeZone|string $timezone
@return \Carbon\Carbon|null | dueDate | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function total()
{
return $this->formatAmount($this->rawTotal());
} | Get the total amount minus the starting balance that was paid (or will be paid).
@return string | total | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function rawTotal()
{
return $this->invoice->total + $this->rawStartingBalance();
} | Get the raw total amount minus the starting balance that was paid (or will be paid).
@return int | rawTotal | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function realTotal()
{
return $this->formatAmount($this->rawRealTotal());
} | Get the total amount that was paid (or will be paid).
@return string | realTotal | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function rawRealTotal()
{
return $this->invoice->total;
} | Get the raw total amount that was paid (or will be paid).
@return int | rawRealTotal | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function subtotal()
{
return $this->formatAmount($this->invoice->subtotal);
} | Get the total of the invoice (before discounts).
@return string | subtotal | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function amountDue()
{
return $this->formatAmount($this->rawAmountDue());
} | Get the amount due for the invoice.
@return string | amountDue | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function rawAmountDue()
{
return $this->invoice->amount_due ?? 0;
} | Get the raw amount due for the invoice.
@return int | rawAmountDue | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function hasStartingBalance()
{
return $this->rawStartingBalance() < 0;
} | Determine if the account had a starting balance.
@return bool | hasStartingBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function startingBalance()
{
return $this->formatAmount($this->rawStartingBalance());
} | Get the starting balance for the invoice.
@return string | startingBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function rawStartingBalance()
{
return $this->invoice->starting_balance ?? 0;
} | Get the raw starting balance for the invoice.
@return int | rawStartingBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function hasEndingBalance()
{
return ! is_null($this->invoice->ending_balance);
} | Determine if the account had an ending balance.
@return bool | hasEndingBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function endingBalance()
{
return $this->formatAmount($this->rawEndingBalance());
} | Get the ending balance for the invoice.
@return string | endingBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function rawEndingBalance()
{
return $this->invoice->ending_balance ?? 0;
} | Get the raw ending balance for the invoice.
@return int | rawEndingBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function hasAppliedBalance()
{
return $this->rawAppliedBalance() < 0;
} | Determine if the invoice has balance applied.
@return bool | hasAppliedBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function appliedBalance()
{
return $this->formatAmount($this->rawAppliedBalance());
} | Get the applied balance for the invoice.
@return string | appliedBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function rawAppliedBalance()
{
return $this->rawStartingBalance() - $this->rawEndingBalance();
} | Get the raw applied balance for the invoice.
@return int | rawAppliedBalance | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function hasDiscount()
{
if (is_null($this->invoice->discounts)) {
return false;
}
return count($this->invoice->discounts) > 0;
} | Determine if the invoice has one or more discounts applied.
@return bool | hasDiscount | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function discounts()
{
if (! is_null($this->discounts)) {
return $this->discounts;
}
$this->refreshWithExpandedData();
return Collection::make($this->invoice->discounts)
->mapInto(Discount::class)
->all();
} | Get all of the discount objects from the Stripe invoice.
@return \Laravel\Cashier\Discount[] | discounts | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
public function discountFor(Discount $discount)
{
if (! is_null($discountAmount = $this->rawDiscountFor($discount))) {
return $this->formatAmount($discountAmount);
}
} | Calculate the amount for a given discount.
@param \Laravel\Cashier\Discount $discount
@return string|null | discountFor | php | laravel/cashier-stripe | src/Invoice.php | https://github.com/laravel/cashier-stripe/blob/master/src/Invoice.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.