Inheritance: extends Illuminate\Database\Eloquent\Model
示例#1
0
 /**
  * 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();
 }
 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();
 }
 /**
  * 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();
 }
 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));
 }
 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);
 }
 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
0
 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;
     }
 }
 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);
     }
 }
 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));
 }
 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
0
 /**
  * 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
0
 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
0
 /**
  * Retrieve all Activities.
  *
  * @param  Request  $request
  * @return Collection|Response
  */
 function index(Request $request)
 {
     try {
         return Activity::all();
     } catch (Exception $e) {
         return response()->error();
     }
 }
 /**
  * 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
0
 /**
  * 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'));
 }
示例#16
0
 public function attachTo(Request $request)
 {
     $this->validate($request, ['classroom_id' => 'required|exists:classrooms,id', 'quiz_id' => 'required|exists:quizzes,id'], ['required' => 'Kolom :attribute diperlukan']);
     $quiz = Quiz::findOrFail($request->quiz_id);
     Activity::create(['teacher_id' => $request->user()->id, 'classroom_id' => $request->classroom_id, 'action' => 'Membagikan quiz ke ', 'route' => 'classrooms.quizdetail', 'detail' => $quiz->id]);
     $quiz->classrooms()->sync([$request->classroom_id], false);
     \Flash::success('Quiz berhasil dibagikan.');
     return redirect()->back();
 }
 /**
  * @param Invoice $invoice
  * @return bool
  */
 public function autoBillInvoice(Invoice $invoice)
 {
     /** @var \App\Models\Client $client */
     $client = $invoice->client;
     /** @var \App\Models\Account $account */
     $account = $client->account;
     /** @var \App\Models\Invitation $invitation */
     $invitation = $invoice->invitations->first();
     if (!$invitation) {
         return false;
     }
     if ($credits = $client->credits->sum('balance')) {
         $balance = $invoice->balance;
         $amount = min($credits, $balance);
         $data = ['payment_type_id' => PAYMENT_TYPE_CREDIT, 'invoice_id' => $invoice->id, 'client_id' => $client->id, 'amount' => $amount];
         $payment = $this->paymentRepo->save($data);
         if ($amount == $balance) {
             return $payment;
         }
     }
     $paymentDriver = $account->paymentDriver($invitation, GATEWAY_TYPE_TOKEN);
     if (!$paymentDriver) {
         return false;
     }
     $customer = $paymentDriver->customer();
     if (!$customer) {
         return false;
     }
     $paymentMethod = $customer->default_payment_method;
     if ($paymentMethod->requiresDelayedAutoBill()) {
         $invoiceDate = \DateTime::createFromFormat('Y-m-d', $invoice->invoice_date);
         $minDueDate = clone $invoiceDate;
         $minDueDate->modify('+10 days');
         if (date_create() < $minDueDate) {
             // Can't auto bill now
             return false;
         }
         if ($invoice->partial > 0) {
             // The amount would be different than the amount in the email
             return false;
         }
         $firstUpdate = Activity::where('invoice_id', '=', $invoice->id)->where('activity_type_id', '=', ACTIVITY_TYPE_UPDATE_INVOICE)->first();
         if ($firstUpdate) {
             $backup = json_decode($firstUpdate->json_backup);
             if ($backup->balance != $invoice->balance || $backup->due_date != $invoice->due_date) {
                 // It's changed since we sent the email can't bill now
                 return false;
             }
         }
         if ($invoice->payments->count()) {
             // ACH requirements are strict; don't auto bill this
             return false;
         }
     }
     return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
 }
示例#18
0
 public function run()
 {
     $disViewMore = false;
     $activities = Activity::find()->where(['belong_to' => $this->belong_to])->orderBy('id DESC')->limit(5)->offset(0)->all();
     $allActivities = Activity::find()->where(['belong_to' => $this->belong_to])->orderBy('id DESC')->all();
     if (count($allActivities) <= 5) {
         $disViewMore = true;
     }
     return $this->render('activities/index', ['activities' => $activities, 'belong_to' => $this->belong_to, 'disViewMore' => $disViewMore]);
 }
示例#19
0
 public function updateAssign($id, $requestData)
 {
     $lead = Leads::findOrFail($id);
     $input = $requestData->get('fk_user_id_assign');
     $input = array_replace($requestData->all());
     $lead->fill($input)->save();
     $insertedName = $lead->assignee->name;
     $activityinput = array_merge(['text' => auth()->user()->name . ' assigned lead to ' . $insertedName, 'user_id' => Auth()->id(), 'type' => 'lead', 'type_id' => $id]);
     Activity::create($activityinput);
 }
示例#20
0
 public function search($params)
 {
     $query = Activity::find()->where(['user_id' => Yii::$app->user->getId()]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 30], 'sort' => ['defaultOrder' => ['start' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'date' => $this->calories, 'val' => $this->peak_heartrate]);
     return $dataProvider;
 }
 public function all($params)
 {
     $params['order'] = isset($params['order']) ? $params['order'] : ['activity_log.created_at|DESC'];
     $activities = Activity::select("activity_log.*");
     $activities->leftJoin('users', 'users.id', '=', 'activity_log.user_id');
     $activities->leftJoin('company_person', 'company_person.id', '=', 'activity_log.contact_id');
     $activities->leftJoin('people', 'people.id', '=', 'company_person.person_id');
     $activities->leftJoin('companies', 'companies.id', '=', 'company_person.company_id');
     $activities = parent::execute($activities, $params);
     return $activities;
 }
示例#22
0
 public function updateAssign($id, $requestData)
 {
     $task = Tasks::with('assignee')->findOrFail($id);
     $input = $requestData->get('fk_user_id_assign');
     $input = array_replace($requestData->all());
     $task->fill($input)->save();
     $task = $task->fresh();
     $insertedName = $task->assignee->name;
     $activityinput = array_merge(['text' => auth()->user()->name . ' assigned task to ' . $insertedName, 'user_id' => auth()->id(), 'type' => 'task', 'type_id' => $id]);
     Activity::create($activityinput);
 }
 public function search($params)
 {
     $query = Activity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere('like', 'description', $this->description);
     return $dataProvider;
 }
示例#24
0
 public function attachTo(Request $request)
 {
     $this->validate($request, ['classroom_id' => 'required|exists:classrooms,id', 'assignment_id' => 'required|exists:assignments,id', 'deadline' => 'required'], ['required' => 'Kolom :attribute diperlukan']);
     $assignment = Assignment::findOrFail($request->assignment_id);
     Activity::create(['teacher_id' => $request->user()->id, 'classroom_id' => $request->classroom_id, 'action' => 'Membagikan tugas ke ', 'route' => 'classrooms.assignmentdetail', 'detail' => $assignment->id]);
     $start = Carbon::parse($request->start);
     $deadline = Carbon::parse($request->deadline);
     $assignment->classrooms()->sync([$request->classroom_id => ['start' => $start, 'deadline' => $deadline]], false);
     \Flash::success('Tugas berhasil dibagikan.');
     return redirect()->back();
 }
示例#25
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $user = auth()->user();
     $followingIds = $user->followers()->lists('follows.follower_id');
     $followingIds->push($user->id);
     $activities = Activity::userIds($followingIds)->latest()->paginate(15);
     $activities->load('user');
     $learnedWords = $user->learnedWords()->count();
     $followers = $user->followees()->notAdmin()->count();
     $following = $user->followers()->notAdmin()->count();
     return view('home')->with('user', $user)->with('activities', $activities)->with('followers', $followers)->with('following', $following)->with('learnedWords', $learnedWords);
 }
示例#26
0
 /**
  * Handle the event.
  *
  * @param  ClientAction  $event
  * @return void
  */
 public function handle(ClientAction $event)
 {
     $client = $event->getClient();
     switch ($event->getAction()) {
         case 'created':
             $text = Lang::get('misc.log.client.created', ['company' => $client->company_name, 'assignee' => $client->AssignedUser->name]);
             break;
         default:
             break;
     }
     $activityinput = array_merge(['text' => $text, 'user_id' => Auth()->id(), 'type' => Client::class, 'type_id' => $client->id, 'action' => $event->getAction()]);
     Activity::create($activityinput);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Activity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category' => $this->category, 'level_id' => $this->level_id, 'recruit_count' => $this->recruit_count, 'sign_up_begin_time' => $this->sign_up_begin_time, 'sign_up_end_time' => $this->sign_up_end_time, 'sign_up_status' => $this->sign_up_status, 'begin_time' => $this->begin_time, 'end_time' => $this->end_time, 'status' => $this->status, 'lesson' => $this->lesson, 'score' => $this->score, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'launch', $this->launch])->andFilterWhere(['like', 'organizers', $this->organizers])->andFilterWhere(['like', 'join_teams', $this->join_teams])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     return $dataProvider;
 }
示例#28
0
 public function search($params)
 {
     $query = Activity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'program_id', $this->program_id]);
     return $dataProvider;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('activities', function ($table) {
         $table->boolean('is_system')->default(0);
     });
     $activities = Activity::where('message', 'like', '%<i>System</i>%')->get();
     foreach ($activities as $activity) {
         $activity->is_system = true;
         $activity->save();
     }
     Schema::table('activities', function ($table) {
         $table->dropColumn('message');
     });
 }
示例#30
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Activity::find()->where(['user_id' => Yii::$app->user->id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }