本文整理汇总了PHP中app\models\Activity类的典型用法代码示例。如果您正苦于以下问题:PHP Activity类的具体用法?PHP Activity怎么用?PHP Activity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$attendance_application = ['user_id' => rand(1, 8), 'activity_type' => 'request', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$attendance_application_update = ['user_id' => rand(1, 8), 'activity_type' => 'update', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$attendance_application_approved = ['user_id' => rand(1, 8), 'activity_type' => 'approved', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$conference_denied = ['user_id' => rand(1, 8), 'activity_type' => 'denied', 'source_id' => rand(1, 4), 'source_type' => 'conference'];
$attendance_application_deleted = ['user_id' => rand(1, 8), 'activity_type' => 'deleted', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$ev_attendance_application = ['user_id' => rand(1, 8), 'activity_type' => 'request', 'source_id' => rand(1, 6), 'source_type' => 'event application', 'profile_id' => rand(1, 8)];
$event_update = ['user_id' => rand(1, 8), 'activity_type' => 'update', 'source_id' => rand(1, 6), 'source_type' => 'event'];
$ev_attendance_application_approved = ['user_id' => rand(1, 8), 'activity_type' => 'approved', 'source_id' => rand(1, 6), 'source_type' => 'event application', 'profile_id' => rand(1, 8)];
$ev_attendance_application_denied = ['user_id' => rand(1, 8), 'activity_type' => 'denied', 'source_id' => rand(1, 6), 'source_type' => 'event application', 'profile_id' => rand(1, 8)];
$ev_deleted = ['user_id' => rand(1, 8), 'activity_type' => 'deleted', 'source_id' => rand(1, 6), 'source_type' => 'event'];
$attendance_application = new Activity($attendance_application);
$attendance_application->save();
$attendance_application_deleted = new Activity($attendance_application_deleted);
$attendance_application_deleted->save();
$attendance_application_approved = new Activity($attendance_application_approved);
$attendance_application_approved->save();
$attendance_application_update = new Activity($attendance_application_update);
$attendance_application_update->save();
$conference_denied = new Activity($conference_denied);
$conference_denied->save();
$ev_deleted = new Activity($ev_deleted);
$ev_deleted->save();
$event_update = new Activity($event_update);
$event_update->save();
$ev_attendance_application = new Activity($ev_attendance_application);
$ev_attendance_application->save();
$ev_attendance_application_denied = new Activity($ev_attendance_application_denied);
$ev_attendance_application_denied->save();
$ev_attendance_application_approved = new Activity($ev_attendance_application_approved);
$ev_attendance_application_approved->save();
}
示例2: log
public static function log($text = null, $params = null, $user_id = null, $contact_id = null)
{
$params = isset($params) ? $params : Request::all();
$browser = "";
foreach ($params as $key => &$param) {
foreach (self::$hides as $hide) {
if (strpos($key, $hide) !== false) {
$param = "***";
}
}
}
$activity = new Activity();
$activity->user_id = isset($user_id) ? $user_id : Auth::user()->id;
$activity->contact_id = isset($contact_id) ? $contact_id : Auth::user()->active_contact->id;
$activity->method = Request::method();
$activity->path = Request::path();
$activity->request = json_encode($params);
$activity->ip_address = Request::ip();
$activity->route = Request::route() ? Request::route()->getName() : NULL;
$activity->text = $text;
$browser = new Browser();
$activity->browser = $browser->getBrowser();
$activity->browser_version = $browser->getVersion();
$activity->os = $browser->getPlatform();
$activity->save();
}
示例3: handle
/**
* Handle the event.
*
* @param PermissionChecked $event
* @return void
*/
public function handle(PermissionChecked $event)
{
$activity = new Activity();
$activity->activity_type = get_class($event->permission);
$activity->activity_id = $event->permission->id;
$activity->user_id = $event->user->id;
$activity->save();
}
示例4: actionCreate
public function actionCreate()
{
$model = new Activity();
if ($model->load(Yii::$app->request->post())) {
$model->save();
//var_dump($model->getErrors()); die;
}
return $this->render('create', array('model' => $model));
}
示例5: index
public function index()
{
// total_income, billed_clients, invoice_sent and active_clients
$select = DB::raw('COUNT(DISTINCT CASE WHEN invoices.id IS NOT NULL THEN clients.id ELSE null END) billed_clients,
SUM(CASE WHEN invoices.invoice_status_id >= ' . INVOICE_STATUS_SENT . ' THEN 1 ELSE 0 END) invoices_sent,
COUNT(DISTINCT clients.id) active_clients');
$metrics = DB::table('accounts')->select($select)->leftJoin('clients', 'accounts.id', '=', 'clients.account_id')->leftJoin('invoices', 'clients.id', '=', 'invoices.client_id')->where('accounts.id', '=', Auth::user()->account_id)->where('clients.is_deleted', '=', false)->where('invoices.is_deleted', '=', false)->where('invoices.is_recurring', '=', false)->where('invoices.is_quote', '=', false)->groupBy('accounts.id')->first();
$select = DB::raw('SUM(clients.paid_to_date) as value, clients.currency_id as currency_id');
$paidToDate = DB::table('accounts')->select($select)->leftJoin('clients', 'accounts.id', '=', 'clients.account_id')->where('accounts.id', '=', Auth::user()->account_id)->where('clients.is_deleted', '=', false)->groupBy('accounts.id')->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))->get();
$select = DB::raw('AVG(invoices.amount) as invoice_avg, clients.currency_id as currency_id');
$averageInvoice = DB::table('accounts')->select($select)->leftJoin('clients', 'accounts.id', '=', 'clients.account_id')->leftJoin('invoices', 'clients.id', '=', 'invoices.client_id')->where('accounts.id', '=', Auth::user()->account_id)->where('clients.is_deleted', '=', false)->where('invoices.is_deleted', '=', false)->where('invoices.is_quote', '=', false)->where('invoices.is_recurring', '=', false)->groupBy('accounts.id')->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))->get();
$select = DB::raw('SUM(clients.balance) as value, clients.currency_id as currency_id');
$balances = DB::table('accounts')->select($select)->leftJoin('clients', 'accounts.id', '=', 'clients.account_id')->where('accounts.id', '=', Auth::user()->account_id)->where('clients.is_deleted', '=', false)->groupBy('accounts.id')->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))->get();
$activities = Activity::where('activities.account_id', '=', Auth::user()->account_id)->where('activity_type_id', '>', 0)->orderBy('created_at', 'desc')->take(50)->get();
$pastDue = DB::table('invoices')->leftJoin('clients', 'clients.id', '=', 'invoices.client_id')->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')->where('invoices.account_id', '=', Auth::user()->account_id)->where('clients.deleted_at', '=', null)->where('contacts.deleted_at', '=', null)->where('invoices.is_recurring', '=', false)->where('invoices.balance', '>', 0)->where('invoices.is_deleted', '=', false)->where('invoices.deleted_at', '=', null)->where('contacts.is_primary', '=', true)->where('invoices.due_date', '<', date('Y-m-d'))->select(['invoices.due_date', 'invoices.balance', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id', 'is_quote'])->orderBy('invoices.due_date', 'asc')->take(50)->get();
$upcoming = DB::table('invoices')->leftJoin('clients', 'clients.id', '=', 'invoices.client_id')->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')->where('invoices.account_id', '=', Auth::user()->account_id)->where('clients.deleted_at', '=', null)->where('contacts.deleted_at', '=', null)->where('invoices.deleted_at', '=', null)->where('invoices.is_recurring', '=', false)->where('invoices.balance', '>', 0)->where('invoices.is_deleted', '=', false)->where('contacts.is_primary', '=', true)->where('invoices.due_date', '>=', date('Y-m-d'))->orderBy('invoices.due_date', 'asc')->take(50)->select(['invoices.due_date', 'invoices.balance', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id', 'is_quote'])->get();
$payments = DB::table('payments')->leftJoin('clients', 'clients.id', '=', 'payments.client_id')->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')->leftJoin('invoices', 'invoices.id', '=', 'payments.invoice_id')->where('payments.account_id', '=', Auth::user()->account_id)->where('clients.deleted_at', '=', null)->where('contacts.deleted_at', '=', null)->where('contacts.is_primary', '=', true)->select(['payments.payment_date', 'payments.amount', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id'])->orderBy('payments.id', 'desc')->take(50)->get();
$hasQuotes = false;
foreach ([$upcoming, $pastDue] as $data) {
foreach ($data as $invoice) {
if ($invoice->is_quote) {
$hasQuotes = true;
}
}
}
$data = ['account' => Auth::user()->account, 'paidToDate' => $paidToDate, 'balances' => $balances, 'averageInvoice' => $averageInvoice, 'invoicesSent' => $metrics ? $metrics->invoices_sent : 0, 'activeClients' => $metrics ? $metrics->active_clients : 0, 'activities' => $activities, 'pastDue' => $pastDue, 'upcoming' => $upcoming, 'payments' => $payments, 'title' => trans('texts.dashboard'), 'hasQuotes' => $hasQuotes];
return View::make('dashboard', $data);
}
示例6: actionList
public function actionList()
{
$query = Activity::find();
$pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
$models = $query->orderby("id DESC")->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render("list", ['models' => $models, 'pagination' => $pagination]);
}
示例7: sendInvitation
private function sendInvitation($invitation, $invoice, $body, $subject, $pdfString)
{
$client = $invoice->client;
$account = $invoice->account;
if (Auth::check()) {
$user = Auth::user();
} else {
$user = $invitation->user;
if ($invitation->user->trashed()) {
$user = $account->users()->orderBy('id')->first();
}
}
if (!$user->email || !$user->confirmed) {
return false;
}
if (!$invitation->contact->email || $invitation->contact->trashed()) {
return false;
}
$variables = ['account' => $account, 'client' => $client, 'invitation' => $invitation, 'amount' => $invoice->getRequestedAmount()];
$data = ['body' => $this->processVariables($body, $variables), 'link' => $invitation->getLink(), 'entityType' => $invoice->getEntityType(), 'invoiceId' => $invoice->id, 'invitation' => $invitation];
if ($account->attatchPDF()) {
$data['pdfString'] = $pdfString;
$data['pdfFileName'] = $invoice->getFileName();
}
$subject = $this->processVariables($subject, $variables);
$fromEmail = $user->email;
$response = $this->sendTo($invitation->contact->email, $fromEmail, $account->getDisplayName(), $subject, ENTITY_INVOICE, $data);
if ($response === true) {
Activity::emailInvoice($invitation);
return true;
} else {
return false;
}
}
示例8: loadHistory
public static function loadHistory($users)
{
$userIds = [];
if (is_array($users)) {
foreach ($users as $user) {
$userIds[] = $user->user_id;
}
} else {
$userIds[] = $users;
}
$activityTypes = [ACTIVITY_TYPE_CREATE_CLIENT, ACTIVITY_TYPE_CREATE_TASK, ACTIVITY_TYPE_UPDATE_TASK, ACTIVITY_TYPE_CREATE_INVOICE, ACTIVITY_TYPE_UPDATE_INVOICE, ACTIVITY_TYPE_EMAIL_INVOICE, ACTIVITY_TYPE_CREATE_QUOTE, ACTIVITY_TYPE_UPDATE_QUOTE, ACTIVITY_TYPE_EMAIL_QUOTE, ACTIVITY_TYPE_VIEW_INVOICE, ACTIVITY_TYPE_VIEW_QUOTE];
$activities = Activity::scope()->with(['client.contacts', 'invoice', 'task'])->whereIn('user_id', $userIds)->whereIn('activity_type_id', $activityTypes)->orderBy('id', 'asc')->limit(100)->get();
foreach ($activities as $activity) {
if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_CLIENT) {
$entity = $activity->client;
} else {
if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_TASK || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_TASK) {
$entity = $activity->task;
$entity->setRelation('client', $activity->client);
} else {
$entity = $activity->invoice;
$entity->setRelation('client', $activity->client);
}
}
static::trackViewed($entity);
}
}
示例9: sendInvoice
public function sendInvoice(Invoice $invoice)
{
$invoice->load('invitations', 'client', 'account');
$entityType = $invoice->getEntityType();
$view = 'invoice';
$subject = trans("texts.{$entityType}_subject", ['invoice' => $invoice->invoice_number, 'account' => $invoice->account->getDisplayName()]);
$accountName = $invoice->account->getDisplayName();
$emailTemplate = $invoice->account->getEmailTemplate($entityType);
$invoiceAmount = Utils::formatMoney($invoice->getRequestedAmount(), $invoice->client->currency_id);
foreach ($invoice->invitations as $invitation) {
if (!$invitation->user || !$invitation->user->email) {
return false;
}
if (!$invitation->contact || !$invitation->contact->email) {
return false;
}
$invitation->sent_date = \Carbon::now()->toDateTimeString();
$invitation->save();
$variables = ['$footer' => $invoice->account->getEmailFooter(), '$link' => $invitation->getLink(), '$client' => $invoice->client->getDisplayName(), '$account' => $accountName, '$contact' => $invitation->contact->getDisplayName(), '$amount' => $invoiceAmount];
$data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate);
$data['link'] = $invitation->getLink();
$data['entityType'] = $entityType;
$data['invoice_id'] = $invoice->id;
$fromEmail = $invitation->user->email;
$this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);
Activity::emailInvoice($invitation);
}
if (!$invoice->isSent()) {
$invoice->invoice_status_id = INVOICE_STATUS_SENT;
$invoice->save();
}
Event::fire(new InvoiceSent($invoice));
}
示例10: sendInvoice
public function sendInvoice(Invoice $invoice, $reminder = false)
{
$invoice->load('invitations', 'client.language', 'account');
$entityType = $invoice->getEntityType();
$client = $invoice->client;
$account = $invoice->account;
if ($invoice->trashed() || $client->trashed()) {
return false;
}
$account->loadLocalizationSettings($client);
if ($account->pdf_email_attachment) {
$invoice->updateCachedPDF();
}
$view = 'invoice';
$accountName = $invoice->account->getDisplayName();
$emailTemplate = $invoice->account->getEmailTemplate($reminder ?: $entityType);
$emailSubject = $invoice->account->getEmailSubject($reminder ?: $entityType);
$this->initClosure($invoice);
$response = false;
$sent = false;
foreach ($invoice->invitations as $invitation) {
if (Auth::check()) {
$user = Auth::user();
} else {
$user = $invitation->user;
if ($invitation->user->trashed()) {
$user = $account->users()->orderBy('id')->first();
}
}
if (!$user->email || !$user->confirmed) {
continue;
}
if (!$invitation->contact->email || $invitation->contact->trashed()) {
continue;
}
$invitation->sent_date = \Carbon::now()->toDateTimeString();
$invitation->save();
$variables = ['account' => $account, 'client' => $client, 'invitation' => $invitation, 'amount' => $invoice->getRequestedAmount()];
$data['body'] = $this->processVariables($emailTemplate, $variables);
$data['link'] = $invitation->getLink();
$data['entityType'] = $entityType;
$data['invoice_id'] = $invoice->id;
$subject = $this->processVariables($emailSubject, $variables);
$fromEmail = $user->email;
$response = $this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);
if ($response === true) {
$sent = true;
Activity::emailInvoice($invitation);
}
}
if ($sent === true) {
if (!$invoice->isSent()) {
$invoice->invoice_status_id = INVOICE_STATUS_SENT;
$invoice->save();
}
$account->loadLocalizationSettings();
Event::fire(new InvoiceSent($invoice));
}
return $response ?: trans('texts.email_error');
}
示例11: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$act = Models\Activity::find($id);
//活动列表
$activities = Models\Activity::select('id', 'title')->get();
return view('home.activity.show', compact('act', 'activities'));
}
示例12: index
public function index()
{
$classroomIds = Auth::user()->joinedClassrooms;
$activities = Activity::whereIn('classroom_id', $classroomIds)->orderBy('created_at', 'DESC')->paginate(10);
$discussions = Discussion::where('parent_id', '')->whereIn('classroom_id', $classroomIds)->orderBy('created_at', 'DESC')->paginate(10);
return view('user.global.feeds', compact('activities', 'discussions'));
}
示例13: index
/**
* Retrieve all Activities.
*
* @param Request $request
* @return Collection|Response
*/
function index(Request $request)
{
try {
return Activity::all();
} catch (Exception $e) {
return response()->error();
}
}
示例14: findModel
/**
* Finds the Activity model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Activity the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Activity::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例15: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//社团列表
$associates = Models\Associate::select('id', 'name', 'poly_id')->take(5)->orderBy('id', 'desc')->get();
//活动列表
$activities = Models\Activity::select('id', 'title')->take(5)->orderBy('id', 'desc')->get();
//->orderBy('name', 'desc')->take(10)->get();
return view('home.index', compact('activities', 'associates'));
}