idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
35,700 | public function listPointsLastHour ( Metric $ metric ) { $ dateTime = $ this -> dates -> make ( ) ; $ pointKey = $ dateTime -> format ( 'Y-m-d H:i' ) ; $ nrOfMinutes = 61 ; $ points = $ this -> repository -> getPointsSinceMinutes ( $ metric , $ nrOfMinutes + $ metric -> threshold ) -> pluck ( 'value' , 'key' ) -> take ... | Returns all points as an array for the last hour . |
35,701 | public function listPointsToday ( Metric $ metric , $ hours = 12 ) { $ dateTime = $ this -> dates -> make ( ) ; $ pointKey = $ dateTime -> format ( 'Y-m-d H:00' ) ; $ points = $ this -> repository -> getPointsSinceHour ( $ metric , $ hours ) -> pluck ( 'value' , 'key' ) ; for ( $ i = 0 ; $ i < $ hours ; $ i ++ ) { if (... | Returns all points as an array by x hours . |
35,702 | protected function getHeaders ( string $ key , int $ limit , int $ after = null , array $ merge = [ ] ) { $ remaining = $ after === null ? $ this -> limiter -> retriesLeft ( $ key , $ limit ) : 0 ; $ headers = [ 'X-RateLimit-Limit' => $ limit , 'X-RateLimit-Remaining' => $ remaining ] ; return array_merge ( $ headers ,... | Get the limit header information . |
35,703 | public function showComponentGroups ( ) { $ this -> subMenu [ 'groups' ] [ 'active' ] = true ; return View :: make ( 'dashboard.components.groups.index' ) -> withPageTitle ( trans_choice ( 'dashboard.components.groups.groups' , 2 ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withGroups ( ComponentGroup :: orderBy ( ... | Shows the component groups view . |
35,704 | public function deleteComponentGroupAction ( ComponentGroup $ group ) { execute ( new RemoveComponentGroupCommand ( $ group ) ) ; return cachet_redirect ( 'dashboard.components.groups' ) -> withSuccess ( sprintf ( '%s %s' , trans ( 'dashboard.notifications.awesome' ) , trans ( 'dashboard.components.delete.success' ) ) ... | Deletes a given component group . |
35,705 | public function showEditComponentGroup ( ComponentGroup $ group ) { return View :: make ( 'dashboard.components.groups.edit' ) -> withPageTitle ( trans ( 'dashboard.components.groups.edit.title' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withGroup ( $ group ) ; } | Shows the edit component group view . |
35,706 | public function updateComponentGroupAction ( ComponentGroup $ group ) { try { $ group = execute ( new UpdateComponentGroupCommand ( $ group , Binput :: get ( 'name' ) , $ group -> order , Binput :: get ( 'collapsed' ) , Binput :: get ( 'visible' ) ) ) ; } catch ( ValidationException $ e ) { return cachet_redirect ( 'da... | Updates a component group . |
35,707 | public function showIncidents ( ) { $ incidents = Incident :: with ( 'user' ) -> orderBy ( 'created_at' , 'desc' ) -> get ( ) ; return View :: make ( 'dashboard.incidents.index' ) -> withPageTitle ( trans ( 'dashboard.incidents.incidents' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withIncidents ( $ incidents ) ; ... | Shows the incidents view . |
35,708 | public function showAddIncident ( ) { return View :: make ( 'dashboard.incidents.add' ) -> withPageTitle ( trans ( 'dashboard.incidents.add.title' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withComponentsInGroups ( ComponentGroup :: with ( 'components' ) -> get ( ) ) -> withComponentsOutGroups ( Component :: wher... | Shows the add incident view . |
35,709 | public function createIncidentAction ( ) { try { $ incident = execute ( new CreateIncidentCommand ( Binput :: get ( 'name' ) , Binput :: get ( 'status' ) , Binput :: get ( 'message' , null , false , false ) , Binput :: get ( 'visible' , true ) , Binput :: get ( 'component_id' ) , Binput :: get ( 'component_status' ) , ... | Creates a new incident . |
35,710 | public function showEditTemplateAction ( IncidentTemplate $ template ) { return View :: make ( 'dashboard.templates.edit' ) -> withPageTitle ( trans ( 'dashboard.incidents.templates.edit.title' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withTemplate ( $ template ) ; } | Shows the edit incident template view . |
35,711 | public function deleteTemplateAction ( IncidentTemplate $ template ) { $ template -> delete ( ) ; return cachet_redirect ( 'dashboard.templates' ) -> withSuccess ( sprintf ( '%s %s' , trans ( 'dashboard.notifications.awesome' ) , trans ( 'dashboard.incidents.templates.delete.success' ) ) ) ; } | Deletes an incident template . |
35,712 | public function createIncidentTemplateAction ( ) { try { IncidentTemplate :: create ( [ 'name' => Binput :: get ( 'name' ) , 'template' => Binput :: get ( 'template' , null , false , false ) , ] ) ; } catch ( ValidationException $ e ) { return cachet_redirect ( 'dashboard.templates.create' ) -> withInput ( Binput :: al... | Creates a new incident template . |
35,713 | public function deleteIncidentAction ( Incident $ incident ) { execute ( new RemoveIncidentCommand ( $ incident ) ) ; return cachet_redirect ( 'dashboard.incidents' ) -> withSuccess ( sprintf ( '%s %s' , trans ( 'dashboard.notifications.awesome' ) , trans ( 'dashboard.incidents.delete.success' ) ) ) ; } | Deletes a given incident . |
35,714 | public function editIncidentAction ( Incident $ incident ) { try { $ incident = execute ( new UpdateIncidentCommand ( $ incident , Binput :: get ( 'name' ) , Binput :: get ( 'status' ) , Binput :: get ( 'message' ) , Binput :: get ( 'visible' , true ) , Binput :: get ( 'component_id' ) , Binput :: get ( 'component_stat... | Edit an incident . |
35,715 | public function editTemplateAction ( IncidentTemplate $ template ) { try { $ template -> update ( Binput :: get ( 'template' ) ) ; } catch ( ValidationException $ e ) { return cachet_redirect ( 'dashboard.templates.edit' , [ 'id' => $ template -> id ] ) -> withUpdatedTemplate ( $ template ) -> withTemplateErrors ( $ e ... | Edit an incident template . |
35,716 | public function showSetupView ( ) { $ this -> subMenu [ 'setup' ] [ 'active' ] = true ; Session :: flash ( 'redirect_to' , $ this -> subMenu [ 'setup' ] [ 'url' ] ) ; return View :: make ( 'dashboard.settings.app-setup' ) -> withPageTitle ( trans ( 'dashboard.settings.app-setup.app-setup' ) . ' - ' . trans ( 'dashboard... | Shows the settings setup view . |
35,717 | public function showSecurityView ( ) { $ this -> subMenu [ 'security' ] [ 'active' ] = true ; $ unsecureUsers = User :: whereNull ( 'google_2fa_secret' ) -> orWhere ( 'google_2fa_secret' , '=' , '' ) -> get ( ) ; Session :: flash ( 'redirect_to' , $ this -> subMenu [ 'security' ] [ 'url' ] ) ; return View :: make ( 'da... | Shows the settings security view . |
35,718 | public function showStylesheetView ( ) { $ this -> subMenu [ 'stylesheet' ] [ 'active' ] = true ; Session :: flash ( 'redirect_to' , $ this -> subMenu [ 'stylesheet' ] [ 'url' ] ) ; return View :: make ( 'dashboard.settings.stylesheet' ) -> withPageTitle ( trans ( 'dashboard.settings.stylesheet.stylesheet' ) . ' - ' . ... | Shows the settings stylesheet view . |
35,719 | public function showCreditsView ( ) { $ this -> subMenu [ 'credits' ] [ 'active' ] = true ; $ credits = app ( Credits :: class ) -> latest ( ) ; $ backers = $ credits [ 'backers' ] ; $ contributors = $ credits [ 'contributors' ] ; shuffle ( $ backers ) ; shuffle ( $ contributors ) ; return View :: make ( 'dashboard.set... | Show the credits view . |
35,720 | public function showLogView ( ) { $ this -> subMenu [ 'log' ] [ 'active' ] = true ; $ log = Log :: getLogger ( ) ; $ logContents = '' ; collect ( $ log -> getHandlers ( ) ) -> reject ( function ( $ handler ) { return $ handler instanceof SyslogHandler ; } ) -> each ( function ( $ handler ) use ( & $ logContents , $ log... | Show the most recent log . |
35,721 | public function postMail ( ) { $ config = Binput :: get ( 'config' ) ; execute ( new UpdateConfigCommand ( $ config ) ) ; return cachet_redirect ( 'dashboard.settings.mail' ) -> withInput ( Binput :: all ( ) ) -> withSuccess ( trans ( 'dashboard.notifications.awesome' ) ) ; } | Handle updating of the settings . |
35,722 | public function postSettings ( ) { $ setting = app ( Repository :: class ) ; if ( Binput :: get ( 'remove_banner' ) === '1' ) { $ setting -> set ( 'app_banner' , null ) ; } $ parameters = Binput :: all ( ) ; if ( isset ( $ parameters [ 'header' ] ) ) { if ( $ header = Binput :: get ( 'header' , null , false , false ) )... | Updates the status page settings . |
35,723 | protected function handleUpdateBanner ( Repository $ setting ) { $ file = Binput :: file ( 'app_banner' ) ; $ redirectUrl = $ this -> subMenu [ 'theme' ] [ 'url' ] ; $ maxSize = $ file -> getMaxFilesize ( ) ; if ( $ file -> getSize ( ) > $ maxSize ) { return Redirect :: to ( $ redirectUrl ) -> withErrors ( trans ( 'das... | Handle updating of the banner image . |
35,724 | public function handle ( CreateIncidentCommand $ command ) { $ data = [ 'user_id' => $ this -> auth -> user ( ) -> id , 'name' => $ command -> name , 'status' => $ command -> status , 'visible' => $ command -> visible , 'stickied' => $ command -> stickied , ] ; if ( $ template = IncidentTemplate :: where ( 'slug' , '='... | Handle the create incident command . |
35,725 | public function showMetrics ( ) { $ metrics = Metric :: orderBy ( 'order' ) -> orderBy ( 'id' ) -> get ( ) ; return View :: make ( 'dashboard.metrics.index' ) -> withPageTitle ( trans ( 'dashboard.metrics.metrics' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withMetrics ( $ metrics ) ; } | Shows the metrics view . |
35,726 | public function createMetricAction ( ) { $ metricData = Binput :: get ( 'metric' ) ; try { execute ( new CreateMetricCommand ( $ metricData [ 'name' ] , $ metricData [ 'suffix' ] , $ metricData [ 'description' ] , $ metricData [ 'default_value' ] , $ metricData [ 'calc_type' ] , $ metricData [ 'display_chart' ] , $ met... | Creates a new metric . |
35,727 | public function deleteMetricAction ( Metric $ metric ) { execute ( new RemoveMetricCommand ( $ metric ) ) ; return cachet_redirect ( 'dashboard.metrics' ) -> withSuccess ( sprintf ( '%s %s' , trans ( 'dashboard.notifications.awesome' ) , trans ( 'dashboard.metrics.delete.success' ) ) ) ; } | Deletes a given metric . |
35,728 | public function showEditMetricAction ( Metric $ metric ) { return View :: make ( 'dashboard.metrics.edit' ) -> withPageTitle ( trans ( 'dashboard.metrics.edit.title' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withMetric ( $ metric ) -> withAcceptableThresholds ( Metric :: ACCEPTABLE_THRESHOLDS ) ; } | Shows the edit metric view . |
35,729 | public function editMetricAction ( Metric $ metric ) { try { execute ( new UpdateMetricCommand ( $ metric , Binput :: get ( 'name' , null , false ) , Binput :: get ( 'suffix' , null , false ) , Binput :: get ( 'description' , null , false ) , Binput :: get ( 'default_value' , null , false ) , Binput :: get ( 'calc_type... | Edit an metric . |
35,730 | public function scopeSort ( Builder $ query , $ column , $ direction ) { if ( ! in_array ( $ column , $ this -> sortable ) ) { return $ query ; } return $ query -> orderBy ( $ column , $ direction ) ; } | Adds a sort scope . |
35,731 | public function all ( ) { try { return $ this -> model -> all ( [ 'name' , 'value' ] ) -> pluck ( 'value' , 'name' ) -> map ( function ( $ value , $ name ) { return $ this -> castSetting ( $ name , $ value ) ; } ) -> toArray ( ) ; } catch ( Exception $ e ) { throw new ReadException ( $ e ) ; } } | Returns a setting from the database . |
35,732 | public function set ( $ name , $ value ) { $ this -> stale = true ; try { if ( $ value === null ) { $ this -> model -> where ( 'name' , '=' , $ name ) -> delete ( ) ; } else { $ this -> model -> updateOrCreate ( compact ( 'name' ) , compact ( 'value' ) ) ; } } catch ( Exception $ e ) { throw new WriteException ( $ e ) ... | Updates a setting value . |
35,733 | public function get ( $ name , $ default = null ) { try { if ( $ setting = $ this -> model -> where ( 'name' , '=' , $ name ) -> first ( ) ) { return $ this -> castSetting ( $ name , $ setting -> value ) ; } return $ default ; } catch ( Exception $ e ) { throw new ReadException ( $ e ) ; } } | Get a setting or the default value . |
35,734 | public function clear ( ) { $ this -> stale = true ; try { $ this -> model -> query ( ) -> delete ( ) ; } catch ( Exception $ e ) { throw new WriteException ( $ e ) ; } } | Clear all settings . |
35,735 | protected function castSetting ( $ key , $ value ) { if ( is_null ( $ value ) ) { return $ value ; } if ( ! in_array ( $ key , $ this -> notBooleans ) && in_array ( $ value , [ '0' , '1' ] ) ) { return ( bool ) $ value ; } return $ value ; } | Cast setting as the applicable type . |
35,736 | public function icon ( ) { if ( isset ( $ this -> icons [ $ this -> wrappedObject -> status ] ) ) { return $ this -> icons [ $ this -> wrappedObject -> status ] ; } } | Present the status with an icon . |
35,737 | public function handle ( CreateMetricCommand $ command ) { $ metric = Metric :: create ( [ 'name' => $ command -> name , 'suffix' => $ command -> suffix , 'description' => $ command -> description , 'default_value' => $ command -> default_value , 'calc_type' => $ command -> calc_type , 'display_chart' => $ command -> d... | Handle the add metric command . |
35,738 | public function index ( ) { if ( app ( Guard :: class ) -> check ( ) ) { $ components = Component :: query ( ) ; } else { $ components = Component :: enabled ( ) ; } if ( $ tags = Binput :: get ( 'tags' ) ) { $ components -> withAnyTags ( $ tags ) ; } $ components -> search ( Binput :: except ( [ 'sort' , 'order' , 'pe... | Get all components . |
35,739 | public function store ( ) { try { $ component = execute ( new CreateComponentCommand ( Binput :: get ( 'name' ) , Binput :: get ( 'description' ) , Binput :: get ( 'status' ) , Binput :: get ( 'link' ) , Binput :: get ( 'order' ) , Binput :: get ( 'group_id' ) , ( bool ) Binput :: get ( 'enabled' , true ) , Binput :: g... | Create a new component . |
35,740 | public function update ( Component $ component ) { try { execute ( new UpdateComponentCommand ( $ component , Binput :: get ( 'name' ) , Binput :: get ( 'description' ) , Binput :: get ( 'status' ) , Binput :: get ( 'link' ) , Binput :: get ( 'order' ) , Binput :: get ( 'group_id' ) , Binput :: get ( 'enabled' , $ comp... | Update an existing component . |
35,741 | public function getIndex ( ) { $ supportedLanguages = Request :: getLanguages ( ) ; $ userLanguage = Config :: get ( 'app.locale' ) ; foreach ( $ supportedLanguages as $ language ) { $ language = str_replace ( '_' , '-' , $ language ) ; if ( isset ( $ this -> langs [ $ language ] ) ) { $ userLanguage = $ language ; bre... | Returns the setup page . |
35,742 | public function postStep1 ( ) { $ postData = Binput :: all ( ) ; $ v = Validator :: make ( $ postData , $ this -> rulesStep1 ) ; $ v -> sometimes ( 'env.mail_host' , 'required' , function ( $ input ) { return $ input -> env [ 'mail_driver' ] === 'smtp' ; } ) ; $ v -> sometimes ( [ 'env.mail_address' , 'env.mail_passwor... | Handles validation on step one of the setup form . |
35,743 | public function postStep2 ( ) { $ postData = Binput :: all ( ) ; $ v = Validator :: make ( $ postData , $ this -> rulesStep1 + $ this -> rulesStep2 ) ; if ( $ v -> passes ( ) ) { return Response :: json ( [ 'status' => 1 ] ) ; } return Response :: json ( [ 'errors' => $ v -> getMessageBag ( ) ] , 400 ) ; } | Handles validation on step two of the setup form . |
35,744 | public function postStep3 ( ) { $ postData = Binput :: all ( ) ; $ v = Validator :: make ( $ postData , $ this -> rulesStep1 + $ this -> rulesStep2 + $ this -> rulesStep3 ) ; if ( $ v -> passes ( ) ) { $ userDetails = Arr :: pull ( $ postData , 'user' ) ; $ user = User :: create ( [ 'username' => $ userDetails [ 'usern... | Handles the actual app setup including user settings and env . |
35,745 | protected function registerBeacon ( ) { $ this -> app -> singleton ( BeaconContract :: class , function ( $ app ) { $ config = $ app [ 'config' ] ; return new Beacon ( $ config ) ; } ) ; } | Register the beacon class . |
35,746 | protected function registerCredits ( ) { $ this -> app -> singleton ( CreditsContract :: class , function ( $ app ) { $ cache = $ app [ 'cache.store' ] ; return new Credits ( $ cache ) ; } ) ; } | Register the credits class . |
35,747 | protected function registerFeed ( ) { $ this -> app -> singleton ( FeedContract :: class , function ( $ app ) { $ cache = $ app [ 'cache.store' ] ; return new Feed ( $ cache ) ; } ) ; } | Register the feed class . |
35,748 | protected function registerSystem ( ) { $ this -> app -> singleton ( SystemContract :: class , function ( Container $ app ) { $ config = $ app [ 'config' ] ; $ auth = $ app [ 'auth.driver' ] ; return new System ( $ config , $ auth ) ; } ) ; } | Register the system class . |
35,749 | protected function registerReleases ( ) { $ this -> app -> singleton ( ReleasesContract :: class , function ( $ app ) { $ cache = $ app [ 'cache.store' ] ; $ token = $ app [ 'config' ] -> get ( 'services.github.token' ) ; return new Releases ( $ cache , $ token ) ; } ) ; } | Register the releases class . |
35,750 | public function handle ( UpdateConfigCommand $ command ) { foreach ( $ command -> values as $ setting => $ value ) { $ this -> writeEnv ( $ setting , $ value ) ; } } | Handle update config command handler instance . |
35,751 | protected function writeEnv ( $ key , $ value ) { $ dir = app ( ) -> environmentPath ( ) ; $ file = app ( ) -> environmentFile ( ) ; $ path = "{$dir}/{$file}" ; try { ( new Dotenv ( $ dir , $ file ) ) -> load ( ) ; $ envKey = strtoupper ( $ key ) ; $ envValue = env ( $ envKey ) ? : 'null' ; file_put_contents ( $ path ,... | Writes to the . env file with given parameters . |
35,752 | public function setCreatedAtAttribute ( $ createdAt ) { if ( ! $ createdAt ) { return ; } if ( ! $ createdAt instanceof DateTime ) { $ createdAt = Carbon :: parse ( $ createdAt ) ; } $ timestamp = $ createdAt -> format ( 'U' ) ; $ timestamp = 30 * round ( $ timestamp / 30 ) ; $ date = Carbon :: createFromFormat ( 'U' ,... | Round the created at value into intervals of 30 seconds . |
35,753 | public function getMetrics ( Metric $ metric ) { $ type = Binput :: get ( 'filter' , AutoPresenter :: decorate ( $ metric ) -> view_name ) ; $ metrics = app ( MetricRepository :: class ) ; switch ( $ type ) { case 'last_hour' : $ metricData = $ metrics -> listPointsLastHour ( $ metric ) ; break ; case 'today' : $ metri... | Returns metrics in a readily formatted way . |
35,754 | public function handle ( RemoveComponentCommand $ command ) { $ component = $ command -> component ; event ( new ComponentWasRemovedEvent ( $ this -> auth -> user ( ) , $ component ) ) ; $ component -> delete ( ) ; } | Handle the remove component command . |
35,755 | public function showComponents ( ) { $ components = Component :: with ( 'group' ) -> orderBy ( 'order' ) -> orderBy ( 'created_at' ) -> get ( ) ; $ this -> subMenu [ 'components' ] [ 'active' ] = true ; return View :: make ( 'dashboard.components.index' ) -> withPageTitle ( trans_choice ( 'dashboard.components.componen... | Shows the components view . |
35,756 | public function showEditComponent ( Component $ component ) { $ groups = ComponentGroup :: all ( ) ; $ pageTitle = sprintf ( '"%s" - %s - %s' , $ component -> name , trans ( 'dashboard.components.edit.title' ) , trans ( 'dashboard.dashboard' ) ) ; return View :: make ( 'dashboard.components.edit' ) -> withPageTitle ( $... | Shows the edit component view . |
35,757 | public function updateComponentAction ( Component $ component ) { $ componentData = Binput :: get ( 'component' ) ; $ tags = Arr :: pull ( $ componentData , 'tags' ) ; try { $ component = execute ( new UpdateComponentCommand ( $ component , $ componentData [ 'name' ] , $ componentData [ 'description' ] , $ componentDat... | Updates a component . |
35,758 | public function deleteComponentAction ( Component $ component ) { execute ( new RemoveComponentCommand ( $ component ) ) ; return cachet_redirect ( 'dashboard.components' ) -> withSuccess ( sprintf ( '%s %s' , trans ( 'dashboard.notifications.awesome' ) , trans ( 'dashboard.components.delete.success' ) ) ) ; } | Deletes a given component . |
35,759 | public function showIndex ( ) { $ schedule = Schedule :: orderBy ( 'created_at' ) -> get ( ) ; return View :: make ( 'dashboard.maintenance.index' ) -> withPageTitle ( trans ( 'dashboard.schedule.schedule' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withSchedule ( $ schedule ) ; } | Lists all scheduled maintenance . |
35,760 | public function showAddSchedule ( ) { $ incidentTemplates = IncidentTemplate :: all ( ) ; return View :: make ( 'dashboard.maintenance.add' ) -> withPageTitle ( trans ( 'dashboard.schedule.add.title' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withIncidentTemplates ( $ incidentTemplates ) ; } | Shows the add schedule maintenance form . |
35,761 | public function addScheduleAction ( ) { try { execute ( new CreateScheduleCommand ( Binput :: get ( 'name' ) , Binput :: get ( 'message' , null , false , false ) , Binput :: get ( 'status' , Schedule :: UPCOMING ) , Binput :: get ( 'scheduled_at' ) , Binput :: get ( 'completed_at' ) , Binput :: get ( 'components' , [ ]... | Creates a new scheduled maintenance . |
35,762 | public function showEditSchedule ( Schedule $ schedule ) { $ incidentTemplates = IncidentTemplate :: all ( ) ; return View :: make ( 'dashboard.maintenance.edit' ) -> withPageTitle ( trans ( 'dashboard.schedule.edit.title' ) . ' - ' . trans ( 'dashboard.dashboard' ) ) -> withIncidentTemplates ( $ incidentTemplates ) ->... | Shows the edit schedule maintenance form . |
35,763 | public function editScheduleAction ( Schedule $ schedule ) { try { $ schedule = execute ( new UpdateScheduleCommand ( $ schedule , Binput :: get ( 'name' , null ) , Binput :: get ( 'message' , null ) , Binput :: get ( 'status' , null ) , Binput :: get ( 'scheduled_at' , null ) , Binput :: get ( 'completed_at' , null ) ... | Updates the given incident . |
35,764 | public function deleteScheduleAction ( Schedule $ schedule ) { execute ( new DeleteScheduleCommand ( $ schedule ) ) ; return cachet_redirect ( 'dashboard.schedule' ) -> withSuccess ( sprintf ( '%s %s' , trans ( 'dashboard.notifications.awesome' ) , trans ( 'dashboard.schedule.delete.success' ) ) ) ; } | Deletes a given schedule . |
35,765 | public function enabled_components_lowest ( ) { if ( is_bool ( $ this -> enabledComponentsLowest ) ) { $ this -> enabledComponentsLowest = $ this -> wrappedObject -> enabled_components_lowest ( ) -> first ( ) ; } return $ this -> enabledComponentsLowest ; } | Return the enabled components from the wrapped object and cache it if need be . |
35,766 | public function is_collapsed ( ) { if ( $ this -> wrappedObject -> collapsed === 0 ) { return false ; } elseif ( $ this -> wrappedObject -> collapsed === 1 ) { return true ; } return $ this -> wrappedObject -> components -> filter ( function ( $ component ) { return $ component -> status > 1 ; } ) -> isEmpty ( ) ; } | Determine if the group should be collapsed . |
35,767 | public function has_subscriber ( $ subscriptions ) { $ enabled_components = $ this -> wrappedObject -> enabled_components ( ) -> orderBy ( 'order' ) -> pluck ( 'id' ) -> toArray ( ) ; $ intersected = array_intersect ( $ enabled_components , $ subscriptions ) ; return count ( $ intersected ) != 0 ; } | Determine if any of the contained components have active subscriptions . |
35,768 | public function handle ( RemoveMetricPointCommand $ command ) { $ metricPoint = $ command -> metricPoint ; event ( new MetricPointWasRemovedEvent ( $ this -> auth -> user ( ) , $ metricPoint ) ) ; $ metricPoint -> delete ( ) ; } | Handle the remove metric point command . |
35,769 | public function scopeAuthenticated ( Builder $ query , $ authenticated ) { return $ query -> when ( ! $ authenticated , function ( Builder $ query ) { return $ query -> whereDoesntHave ( 'group' , function ( Builder $ query ) { $ query -> where ( 'visible' , ComponentGroup :: VISIBLE_AUTHENTICATED ) ; } ) ; } ) ; } | Find all components which are within visible groups . |
35,770 | public function showDashboard ( ) { $ components = Component :: orderBy ( 'order' ) -> get ( ) ; $ incidents = $ this -> getIncidents ( ) ; $ subscribers = $ this -> getSubscribers ( ) ; $ componentGroups = $ this -> getVisibleGroupedComponents ( ) ; $ ungroupedComponents = Component :: ungrouped ( ) -> get ( ) ; $ wel... | Shows the dashboard view . |
35,771 | protected function getIncidents ( ) { $ allIncidents = Incident :: whereBetween ( 'occurred_at' , [ $ this -> startDate -> copy ( ) -> subDays ( 30 ) -> format ( 'Y-m-d' ) . ' 00:00:00' , $ this -> startDate -> format ( 'Y-m-d' ) . ' 23:59:59' , ] ) -> orderBy ( 'occurred_at' , 'desc' ) -> get ( ) -> groupBy ( function... | Fetches all of the incidents over the last 30 days . |
35,772 | protected function getSubscribers ( ) { $ allSubscribers = Subscriber :: whereBetween ( 'created_at' , [ $ this -> startDate -> copy ( ) -> subDays ( 30 ) -> format ( 'Y-m-d' ) . ' 00:00:00' , $ this -> startDate -> format ( 'Y-m-d' ) . ' 23:59:59' , ] ) -> orderBy ( 'created_at' , 'desc' ) -> get ( ) -> groupBy ( func... | Fetches all of the subscribers over the last 30 days . |
35,773 | public function scopeSearch ( Builder $ query , array $ search = [ ] ) { if ( empty ( $ search ) ) { return $ query ; } if ( ! array_intersect ( array_keys ( $ search ) , $ this -> searchable ) ) { return $ query ; } return $ query -> where ( $ search ) ; } | Adds a search scope . |
35,774 | public function handle ( UpdateIncidentUpdateCommand $ command ) { $ command -> update -> update ( $ this -> filter ( $ command ) ) ; event ( new IncidentUpdateWasUpdatedEvent ( $ this -> auth -> user ( ) , $ command -> update ) ) ; return $ command -> update ; } | Handle the update incident update command . |
35,775 | public function handle ( UnsubscribeSubscriptionCommand $ command ) { $ subscription = $ command -> subscription ; event ( new SubscriberHasUnsubscribedEvent ( $ subscription -> subscriber ) ) ; $ subscription -> delete ( ) ; } | Handle the unsubscribe subscription command . |
35,776 | public function postUser ( ) { $ userData = array_filter ( Binput :: only ( [ 'username' , 'email' , 'password' , 'google2fa' ] ) ) ; $ enable2FA = ( bool ) Arr :: pull ( $ userData , 'google2fa' ) ; if ( $ enable2FA && ! Auth :: user ( ) -> hasTwoFactor ) { event ( new UserEnabledTwoAuthEvent ( Auth :: user ( ) ) ) ; ... | Updates the current user . |
35,777 | public function regenerateApiKey ( User $ user ) { $ user -> api_key = User :: generateApiKey ( ) ; $ user -> save ( ) ; event ( new UserRegeneratedApiTokenEvent ( $ user ) ) ; return cachet_redirect ( 'dashboard.user' ) ; } | Regenerates the users API key . |
35,778 | public function getSignup ( $ code = null ) { if ( $ code === null ) { throw new NotFoundHttpException ( ) ; } $ invite = Invite :: where ( 'code' , '=' , $ code ) -> first ( ) ; if ( ! $ invite || $ invite -> is_claimed ) { throw new BadRequestHttpException ( ) ; } return View :: make ( 'signup' ) -> withCode ( $ invi... | Handle the signup with invite . |
35,779 | public function postSignup ( $ code = null ) { if ( $ code === null ) { throw new NotFoundHttpException ( ) ; } $ invite = Invite :: where ( 'code' , '=' , $ code ) -> first ( ) ; if ( ! $ invite || $ invite -> is_claimed ) { throw new BadRequestHttpException ( ) ; } try { execute ( new SignupUserCommand ( Binput :: ge... | Handle a signup request . |
35,780 | public function index ( ) { $ subscribers = Subscriber :: paginate ( Binput :: get ( 'per_page' , 20 ) ) ; return $ this -> paginator ( $ subscribers , Request :: instance ( ) ) ; } | Get all subscribers . |
35,781 | public function parse ( Request $ request ) { $ route = $ request -> route ( ) ; if ( is_callable ( [ $ route , 'parameter' ] ) ) { return $ route -> parameter ( $ this -> key ) ; } } | Try to get the token from the route parameters . |
35,782 | public function add ( $ key , $ value , $ minutes ) { if ( $ this -> laravelVersion !== null && is_int ( $ minutes ) && version_compare ( $ this -> laravelVersion , '5.8' , '>=' ) ) { $ minutes = $ minutes * 60 ; } $ this -> cache ( ) -> put ( $ key , $ value , $ minutes ) ; } | Add a new item into storage . |
35,783 | protected function cache ( ) { if ( $ this -> supportsTags === null ) { $ this -> determineTagSupport ( ) ; } if ( $ this -> supportsTags ) { return $ this -> cache -> tags ( $ this -> tag ) ; } return $ this -> cache ; } | Return the cache instance with tags attached . |
35,784 | public function byId ( $ id ) { if ( $ user = $ this -> sentinel -> getUserRepository ( ) -> findById ( $ id ) ) { $ this -> sentinel -> setUser ( $ user ) ; return true ; } return false ; } | Authenticate a user via the id . |
35,785 | public function matches ( array $ values , $ strict = false ) { if ( empty ( $ values ) ) { return false ; } $ claims = $ this -> getClaims ( ) ; foreach ( $ values as $ key => $ value ) { if ( ! $ claims -> has ( $ key ) || ! $ claims -> get ( $ key ) -> matches ( $ value , $ strict ) ) { return false ; } } return tru... | Checks if a payload matches some expected values . |
35,786 | public function getByClaimName ( $ name , callable $ callback = null , $ default = null ) { return $ this -> filter ( function ( Claim $ claim ) use ( $ name ) { return $ claim -> getName ( ) === $ name ; } ) -> first ( $ callback , $ default ) ; } | Get a Claim instance by it s unique name . |
35,787 | public function validate ( $ context = 'payload' ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; $ this -> each ( function ( $ claim ) use ( $ context , $ args ) { call_user_func_array ( [ $ claim , 'validate' . Str :: ucfirst ( $ context ) ] , $ args ) ; } ) ; return $ this ; } | Validate each claim under a given context . |
35,788 | private function sanitizeClaims ( $ items ) { $ claims = [ ] ; foreach ( $ items as $ key => $ value ) { if ( ! is_string ( $ key ) && $ value instanceof Claim ) { $ key = $ value -> getName ( ) ; } $ claims [ $ key ] = $ value ; } return $ claims ; } | Ensure that the given claims array is keyed by the claim name . |
35,789 | public function has ( Payload $ payload ) { $ val = $ this -> storage -> get ( $ this -> getKey ( $ payload ) ) ; if ( $ val === 'forever' ) { return true ; } return ! empty ( $ val ) && ! Utils :: isFuture ( $ val [ 'valid_until' ] ) ; } | Determine whether the token has been blacklisted . |
35,790 | public static function isPast ( $ timestamp , $ leeway = 0 ) { $ timestamp = static :: timestamp ( $ timestamp ) ; return $ leeway > 0 ? $ timestamp -> addSeconds ( $ leeway ) -> isPast ( ) : $ timestamp -> isPast ( ) ; } | Checks if a timestamp is in the past . |
35,791 | public static function isFuture ( $ timestamp , $ leeway = 0 ) { $ timestamp = static :: timestamp ( $ timestamp ) ; return $ leeway > 0 ? $ timestamp -> subSeconds ( $ leeway ) -> isFuture ( ) : $ timestamp -> isFuture ( ) ; } | Checks if a timestamp is in the future . |
35,792 | public function attempt ( array $ credentials ) { if ( ! $ this -> auth -> byCredentials ( $ credentials ) ) { return false ; } return $ this -> fromUser ( $ this -> user ( ) ) ; } | Attempt to authenticate the user and return the token . |
35,793 | protected function addClaims ( array $ claims ) { foreach ( $ claims as $ name => $ value ) { $ this -> addClaim ( $ name , $ value ) ; } return $ this ; } | Add an array of claims to the Payload . |
35,794 | public function fromSubject ( JWTSubject $ subject ) { $ payload = $ this -> makePayload ( $ subject ) ; return $ this -> manager -> encode ( $ payload ) -> get ( ) ; } | Generate a token for a given subject . |
35,795 | protected function getClaimsForSubject ( JWTSubject $ subject ) { return array_merge ( [ 'sub' => $ subject -> getJWTIdentifier ( ) , ] , $ this -> lockSubject ? [ 'prv' => $ this -> hashSubjectModel ( $ subject ) ] : [ ] ) ; } | Get the claims associated with a given subject . |
35,796 | public function checkSubjectModel ( $ model ) { if ( ( $ prv = $ this -> payload ( ) -> get ( 'prv' ) ) === null ) { return true ; } return $ this -> hashSubjectModel ( $ model ) === $ prv ; } | Check if the subject model matches the one saved in the token . |
35,797 | public function parse ( Request $ request ) { if ( $ this -> decrypt && $ request -> hasCookie ( $ this -> key ) ) { return Crypt :: decrypt ( $ request -> cookie ( $ this -> key ) ) ; } return $ request -> cookie ( $ this -> key ) ; } | Try to parse the token from the request cookies . |
35,798 | protected function setAuthenticationHeader ( $ response , $ token = null ) { $ token = $ token ? : $ this -> auth -> refresh ( ) ; $ response -> headers -> set ( 'Authorization' , 'Bearer ' . $ token ) ; return $ response ; } | Set the authentication header . |
35,799 | protected function getSigner ( ) { if ( ! array_key_exists ( $ this -> algo , $ this -> signers ) ) { throw new JWTException ( 'The given algorithm could not be found' ) ; } return new $ this -> signers [ $ this -> algo ] ; } | Get the signer instance . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.