本文整理汇总了PHP中Subscription::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::where方法的具体用法?PHP Subscription::where怎么用?PHP Subscription::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::where方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Check stripe data.
*
* @access public
* @return void
*/
public function run()
{
$paymentGateway = Payment_gateways::findOneActiveBySlug('stripe');
if ($paymentGateway->exists()) {
\Stripe\Stripe::setApiKey($paymentGateway->getFieldValue('apiKey'));
$subscriptions = new Subscription();
$allSubscriptions = $subscriptions->where('status', Subscription::STATUS_ACTIVE)->get();
/* @var Subscription $_subscription */
foreach ($allSubscriptions as $_subscription) {
$end = DateTime::createFromFormat('Y-m-d', $_subscription->end_date);
if ($end->getTimestamp() > strtotime('now')) {
$paymentTransaction = $_subscription->payment_transaction->get();
if ($paymentTransaction->system == 'stripe') {
$user = new User($_subscription->user_id);
try {
$customer = \Stripe\Customer::retrieve($user->stripe_id);
$subscription = $customer->subscriptions->retrieve($paymentTransaction->payment_id);
} catch (Exception $e) {
log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
}
if (!isset($subscription) || $subscription->status != 'active') {
$_subscription->deactivate();
$_subscription->save();
}
}
}
}
log_message('CRON_SUCCESS', __FUNCTION__);
}
}
示例2: subscribe
public function subscribe()
{
$eventId = Utils::lookupEventId(trim(Input::get('event')));
if (!$eventId) {
return Response::json('', 500);
}
$subscription = Subscription::where('account_id', '=', Auth::user()->account_id)->where('event_id', '=', $eventId)->first();
if (!$subscription) {
$subscription = new Subscription();
$subscription->account_id = Auth::user()->account_id;
$subscription->event_id = $eventId;
}
$subscription->target_url = trim(Input::get('target_url'));
$subscription->save();
return Response::json('{"id":' . $subscription->id . '}', 201);
}
示例3: show
public function show($id)
{
$aangemelde_user = Subscription::where(['user_id' => \Auth::user()->id, 'cursus_id' => $id])->first();
// $check_subscriptions = \DB::table('curcist_cursus')->where('cursus_id', '=', $id)->get();
// $getSoortcursus = \DB::table('soortcursus')->where('id', '=', $id)->get();
// $aangemelde_user = false;
//
// if($check_user) {
// if ($check_user->cursus_id == $id) {
// $aangemelde_user = true;
// }
// }
$cursus = Cursus::with('soortcursus')->FindOrfail($id);
$users = $cursus->subscribers;
return view('subscribe.show', compact('cursus', 'users', 'aangemelde_user'));
}
示例4: processSubscriptions
public function processSubscriptions($status_id, $browser_debug = false)
{
if ($status_id === Config::get('eenvoudcrm.subscriptions_status_terminated.id') || $status_id === Config::get('eenvoudcrm.subscriptions_status_ended.id')) {
$this->log_msg('Error: The Provided subscription status_id is non-renewable', $browser_debug, 'error');
return;
}
$dateIntervals = Config::get('eenvoudcrm.subscriptions_dateintervals');
$withstanding_subscriptions = Subscription::where('subscription_end', '<', date('Y-m-d'))->where('status_id', '=', $status_id)->get();
$results_exist = count($withstanding_subscriptions) > 0;
$this->log_msg(">>> " . count($withstanding_subscriptions) . " " . $dateIntervals[$status_id] . " subscriptions to renew", $browser_debug, $results_exist ? 'question' : 'comment');
foreach ($withstanding_subscriptions as $curr_ndx => $curr_subscription) {
if (!array_key_exists($curr_subscription->status_id, $dateIntervals)) {
// what to do ???
$this->log_msg('Error: Invalid status_id for subscription $curr_subscription->id - $curr_subscription->status_id', $browser_debug, 'error');
return;
}
$new_subscription = clone $curr_subscription;
unset($new_subscription->id);
$new_subscription->subscription_start = date("Y-m-d", strtotime($curr_subscription->subscription_end . " +1 day"));
$new_subscription->subscription_end = date("Y-m-d", strtotime($curr_subscription->subscription_end . $dateIntervals[$curr_subscription->status_id]));
$new_subscription->invoice_id = null;
$new_subscription->status_date = date("Y-m-d");
// prices update ???
//$new_subscription->save();
// disable old subscription
$curr_subscription->status_id = Config::get('eenvoudcrm.subscriptions_status_ended.id');
$curr_subscription->status_date = date("Y-m-d");
//$curr_subscription->save();
$old_msg = "OLD - Start:" . $curr_subscription->subscription_start . " End: " . $curr_subscription->subscription_end . " Status: " . $curr_subscription->status_id . " Status Date: " . $curr_subscription->status_date;
$this->log_msg($old_msg, $browser_debug, 'error');
$new_msg = "NEW - Start:" . $new_subscription->subscription_start . " End: " . $new_subscription->subscription_end . " Status: " . $new_subscription->status_id . " Status Date: " . $new_subscription->status_date;
$this->log_msg($new_msg, $browser_debug, 'info');
}
if ($results_exist) {
$this->log_msg("", $browser_debug);
}
}
示例5: getSubscription
public function getSubscription($eventId)
{
return Subscription::where('account_id', '=', $this->id)->where('event_id', '=', $eventId)->first();
}
示例6: subscribe
public function subscribe($user_id)
{
$validator = Validator::make(array('id' => $user_id), array('id' => 'numeric'));
if ($validator->fails()) {
return $this->respondInsufficientPrivileges($validator->messages()->all());
}
$category_id = Input::get('category_id');
if (Subscription::where('category_id', '=', $category_id)->first()) {
return $this->respondInsufficientPrivileges('Already subscribed');
}
if ($category_id) {
$subscription = Subscription::create(array('user_id' => $user_id, 'category_id' => $category_id));
return $this->respond(array('user_id' => $user_id, 'category_id' => $category_id, 'id' => $subscription['id']));
}
return $this->respondNotFound();
}
示例7: postPayment
public function postPayment()
{
if (Auth::check()) {
$rules = array('paylane_token' => 'required', 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email', 'address' => 'required', 'zip' => 'required', 'city' => 'required', 'state' => 'required', 'company_name' => 'required_with:faktura', 'company_id' => 'required_with:faktura', 'company_address' => 'required_with:faktura', 'company_zip' => 'required_with:faktura', 'company_city' => 'required_with:faktura', 'company_state' => 'required_with:faktura');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
$messages = $validator->messages();
return Redirect::to('/konto/pro/platnosci')->withInput(Input::flash())->withErrors($validator)->with('alert', array('type' => 'error', 'content' => 'Błąd! Sprawdź wszystkie pola.'));
} else {
$user = Auth::user();
$client = new Paylane\PayLaneRestClient('adubiel', 'dru9pra2');
$card_params = array('sale' => array('amount' => 189.0, 'currency' => 'PLN', 'description' => 'Subskrypcja Hasztag.info'), 'customer' => array('name' => Input::get('first_name') . ' ' . Input::get('last_name'), 'email' => Input::get('email'), 'ip' => '127.0.0.1', 'address' => array('street_house' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'), 'country_code' => 'PL')), 'card' => array('token' => Input::get('paylane_token')));
$status = $client->cardSaleByToken($card_params);
if ($client->isSuccess()) {
$subscription = Subscription::where('user_id', '=', $user->id);
$faktura = false;
if ($subscription->count() > 0) {
$subscription = $subscription->first();
$subscription->user_id = $user->id;
$subscription->is_active = 1;
$subscription->first_name = Input::get('first_name');
$subscription->last_name = Input::get('last_name');
$subscription->email = Input::get('email');
$subscription->address = Input::get('address');
$subscription->zip = Input::get('zip');
$subscription->city = Input::get('city');
$subscription->state = Input::get('state');
$subscription->expires_at = Carbon::now()->addDays(30);
if (Input::has('faktura')) {
$faktura = true;
$subscription->is_active = 1;
$subscription->company_name = Input::get('company_name');
$subscription->company_id = preg_replace('/\\D/', '', Input::get('company_id'));
$subscription->company_address = Input::get('company_address');
$subscription->company_city = Input::get('company_city');
$subscription->company_state = Input::get('company_state');
$subscription->company_zip = Input::get('company_zip');
}
$subscription->save();
} else {
$subscription = new Subscription();
$subscription->user_id = $user->id;
$subscription->first_name = Input::get('first_name');
$subscription->last_name = Input::get('last_name');
$subscription->email = Input::get('email');
$subscription->address = Input::get('address');
$subscription->zip = Input::get('zip');
$subscription->city = Input::get('city');
$subscription->state = Input::get('state');
$subscription->expires_at = Carbon::now()->addDays(30);
if (Input::has('faktura')) {
$faktura = true;
$subscription->company_name = Input::get('company_name');
$subscription->company_id = preg_replace('/\\D/', '', Input::get('company_id'));
$subscription->company_address = Input::get('company_address');
$subscription->company_city = Input::get('company_city');
$subscription->company_state = Input::get('company_state');
$subscription->company_zip = Input::get('company_zip');
}
$subscription->save();
}
$payment = Payment::create(array('user_id' => $user->id, 'subscription_id' => $subscription->id, 'sale_id' => $status['id_sale'], 'is_success' => 1));
Event::fire('invoice.email', array($user->id, $subscription->id, $payment->id, $faktura));
EmailNotification::where('subscription_id', '=', $subscription->id)->delete();
//here
$user->level = 2;
$user->save();
return Redirect::to('/konto/pro/subskrypcja')->with('alert', array('type' => 'success', 'content' => 'Dziękujemy! Płatność zaakceptowana.'));
} else {
if (isset($status['error'])) {
return Redirect::back()->with('alert', array('type' => 'error', 'content' => $status['error']['error_description']));
return Redirect::back()->with('alert', array('type' => 'error', 'content' => $status['error']['description']));
} else {
return Redirect::back()->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak!'));
}
}
}
}
}
示例8: postCSVUpload
public function postCSVUpload()
{
$input = Input::all();
error_log(json_encode($input));
// validation
$rules = array('file' => 'mimes:csv,txt');
$validation = Validator::make($input, $rules);
if ($validation->fails()) {
return Response::make($validation->errors->first(), 400);
}
// check for duplicates and move to uploads dir
$file = Input::file('file');
$destinationPath = 'uploads';
$filename = $file->getClientOriginalName();
$file_path = public_path() . '/' . $destinationPath . '/' . $filename;
// get rid of old entries
Emailusage::where('filename', $filename)->delete();
// delete old file
if (File::exists($file_path)) {
File::delete($file_path);
}
// move new file
$upload_success = Input::file('file')->move($destinationPath, $filename);
if ($upload_success) {
$handle = fopen($file_path, 'r');
while (($line = fgetcsv($handle)) !== FALSE) {
// aws account
$curr_aws_account = $line[1];
// 1st line of col labels
if (!is_numeric($curr_aws_account)) {
//error_log($curr_aws_account." not numeric ):");
continue;
}
$cat_cmp = strcmp($line[4], 'Amazon Simple Email Service');
if ($cat_cmp !== 0) {
//error_log($cat_cmp." Cat not relevant ".$line[4]);
continue;
}
$mail_service_cmp = strpos(strtolower($line[5]), strtolower('Cost per recipient of SendEmail'));
$attachments_service_cmp = strpos(strtolower($line[5]), strtolower('Cost per GB of attachments'));
if ($mail_service_cmp === false && $attachments_service_cmp === false) {
error_log($service_cmp . " Service not relevant " . $line[5]);
continue;
}
//$line is an array of the csv elements
$num_columns = count($line);
error_log(">>> LINE " . json_encode($line));
// get the corresponding company_id
$company_meta = CompanyMeta::where('type', 'aws')->where('subtype', 'auth')->where('key', 'account')->where('value', $curr_aws_account)->first();
$company_id = -1;
if ($company_meta) {
$company_id = $company_meta->company_id;
error_log($company_id . " Company FOUND :)");
}
// Error no company found
if ($company_id === -1) {
error_log("Company NOT found ):");
continue;
}
// use start date for period
$curr_period = explode(" ", $line[2])[0];
error_log("Curr period " . $curr_period);
// make sure day is 1st of the month
// so that date can de used as a month tag ?
//
// get the subscription
$email_subscription = Subscription::where("service_id", Config::get('eenvoudcrm.nieuwsbrieven_service_id'))->where('company_id', $company_id)->first();
if (!$email_subscription) {
error_log("Consistency check falure - no nieuwsbrieven subscription (28) found");
continue;
}
$mail_bill_type = $mail_service_cmp === false ? 'attach' : 'mail';
// search emailusage table for already existing entries
$curr_emailusage = Emailusage::where('type', $mail_bill_type)->where('period', '=', $curr_period)->where('subscription_id', '=', $email_subscription->id)->first();
// if they exist update
if ($curr_emailusage) {
//update
error_log('update ' . json_encode($curr_emailusage));
$curr_emailusage->type = $mail_bill_type;
$curr_emailusage->cnt = $line[6];
$curr_emailusage->filename = $filename;
$curr_emailusage->save();
} else {
// get the subscription
$email_subscription = Subscription::whereRaw("service_id=" . Config::get('eenvoudcrm.nieuwsbrieven_service_id') . " AND company_id={$company_id}")->first();
error_log('create ' . json_encode($email_subscription));
if ($email_subscription) {
$curr_emailusage = new Emailusage();
$curr_emailusage->type = $mail_bill_type;
$curr_emailusage->subscription_id = $email_subscription->id;
$curr_emailusage->period = $curr_period;
$curr_emailusage->cnt = $line[6];
$curr_emailusage->filename = $filename;
$curr_emailusage->save();
error_log(json_encode($curr_emailusage));
} else {
error_log("No niewsbrieven subscriptions for " . $company_id);
}
}
}
//.........这里部分代码省略.........