idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
50,300 | public function asset ( $ path , $ contentType = 'null' , $ fullURL = true ) { if ( ! $ fullURL ) { return base_path ( __DIR__ . '/../Assets/' . $ path ) ; } return url ( $ this -> backendRoute . '/asset/' . CryptoServiceFacade :: url_encode ( $ path ) . '/' . CryptoServiceFacade :: url_encode ( $ contentType ) ) ; } | Get a module s asset . |
50,301 | public function languageLinks ( $ linkClass = 'nav-link' , $ itemClass = 'nav-item' ) { if ( count ( config ( 'cms.languages' ) ) > 1 ) { $ languageLinks = [ ] ; foreach ( config ( 'cms.languages' ) as $ key => $ value ) { $ url = url ( config ( 'cms.backend-route-prefix' , 'cms' ) . '/language/set/' . $ key ) ; $ lang... | Links for each supported language |
50,302 | public function notification ( $ string , $ type = null ) { if ( is_null ( $ type ) ) { $ type = 'info' ; } Session :: flash ( 'notification' , $ string ) ; Session :: flash ( 'notificationType' , 'alert-' . $ type ) ; } | Generates a notification for the app . |
50,303 | public function breadcrumbs ( $ locations ) { $ trail = '' ; foreach ( $ locations as $ location ) { if ( is_array ( $ location ) ) { foreach ( $ location as $ key => $ value ) { $ trail .= '<li class="breadcrumb-item"><a href="' . $ value . '">' . ucfirst ( $ key ) . '</a></li>' ; } } else { $ trail .= '<li class="bre... | Creates a breadcrumb trail . |
50,304 | public function config ( $ key ) { $ splitKey = explode ( '.' , $ key ) ; $ moduleConfig = include __DIR__ . '/../PublishedAssets/Config/' . $ splitKey [ 0 ] . '.php' ; $ strippedKey = preg_replace ( '/' . $ splitKey [ 1 ] . './' , '' , preg_replace ( '/' . $ splitKey [ 0 ] . './' , '' , $ key , 1 ) , 1 ) ; return $ mo... | Get Module Config . |
50,305 | public function assignArrayByPath ( & $ arr , $ path ) { $ keys = explode ( '.' , $ path ) ; while ( $ key = array_shift ( $ keys ) ) { $ arr = & $ arr [ $ key ] ; } return $ arr ; } | Assign a value to the path . |
50,306 | public function addToPackages ( $ dir ) { $ files = glob ( $ dir . '/*' ) ; $ packageViews = Config :: get ( 'cms.package-menus' ) ; if ( is_null ( $ packageViews ) ) { $ packageViews = [ ] ; } foreach ( $ files as $ view ) { array_push ( $ packageViews , $ view ) ; } return Config :: set ( 'cms.package-menus' , $ pack... | Add these views to the packages . |
50,307 | public function editBtn ( $ type = null , $ id = null , $ class = "btn-outline-secondary" ) { if ( Gate :: allows ( 'cms' , Auth :: user ( ) ) ) { if ( ! is_null ( $ id ) ) { return '<a href="' . url ( $ this -> backendRoute . '/' . $ type . '/' . $ id . '/edit' ) . '" class="btn btn-sm ' . $ class . '"><span class="fa... | Edit button . |
50,308 | public function rollbackUrl ( $ object ) { $ class = str_replace ( '\\' , '_' , get_class ( $ object ) ) ; return url ( $ this -> backendRoute . '/rollback/' . $ class . '/' . $ object -> id ) ; } | Rollback URL . |
50,309 | public function version ( ) { $ changelog = @ file_get_contents ( __DIR__ . '/../../changelog.md' ) ; if ( ! $ changelog ) { return 'unknown version' ; } $ matches = strstr ( $ changelog , '## [' ) ; $ until = strpos ( $ matches , '-' ) ; return str_replace ( ']' , '' , substr ( $ matches , 5 , $ until - 5 ) ) ; } | Get version from the changelog . |
50,310 | public function collectSiteMapItems ( ) { $ itemCollection = [ ] ; $ modules = config ( 'site-mapped-modules' , [ 'blog' => 'Grafite\Cms\Repositories\BlogRepository' , 'page' => 'Grafite\Cms\Repositories\PageRepository' , 'events' => 'Grafite\Cms\Repositories\EventRepository' , ] ) ; foreach ( $ modules as $ module => ... | Collect items for a site map |
50,311 | public function getTemplatesAsOptionsArray ( $ module ) { $ availableTemplates = [ 'show' ] ; $ templates = glob ( base_path ( 'resources/themes/' . config ( 'cms.frontend-theme' ) . '/' . $ module . '/*' ) ) ; foreach ( $ templates as $ template ) { $ template = str_replace ( base_path ( 'resources/themes/' . config (... | Get templates as options |
50,312 | public function update ( $ widget , $ payload ) { $ payload [ 'name' ] = htmlentities ( $ payload [ 'name' ] ) ; if ( ! empty ( $ payload [ 'lang' ] ) && $ payload [ 'lang' ] !== config ( 'cms.default-language' , 'en' ) ) { return $ this -> translationRepo -> createOrUpdate ( $ widget -> id , 'Grafite\Cms\Models\Widget... | Updates Widget in the database |
50,313 | public function translationData ( $ lang ) { $ translation = $ this -> translation ( $ lang ) ; if ( $ translation ) { $ data = json_decode ( $ translation -> entity_data ) ; if ( isset ( $ data -> blocks ) ) { $ data -> blocks = json_decode ( $ data -> blocks , true ) ; } return $ data ; } return null ; } | Get translation data . |
50,314 | public function getTranslationsAttribute ( ) { $ translationData = [ ] ; $ translations = Translation :: where ( 'entity_id' , $ this -> id ) -> where ( 'entity_type' , get_class ( $ this ) ) -> get ( ) ; foreach ( $ translations as $ translation ) { $ translationData [ ] = $ translation -> data -> attributes ; } retur... | Get a translations attribute . |
50,315 | public function afterCreate ( $ payload ) { if ( config ( 'cms.auto-translate' , false ) ) { $ entry = $ payload -> toArray ( ) ; unset ( $ entry [ 'created_at' ] ) ; unset ( $ entry [ 'updated_at' ] ) ; unset ( $ entry [ 'translations' ] ) ; unset ( $ entry [ 'is_published' ] ) ; unset ( $ entry [ 'published_at' ] ) ;... | After the item is created in the database . |
50,316 | public function index ( ) { $ blogs = $ this -> repository -> paginated ( ) ; return view ( 'cms::modules.blogs.index' ) -> with ( 'blogs' , $ blogs ) -> with ( 'pagination' , $ blogs -> render ( ) ) ; } | Display a listing of the Blog . |
50,317 | public function store ( Request $ request ) { $ validation = app ( ValidationService :: class ) -> check ( Blog :: $ rules ) ; if ( ! $ validation [ 'errors' ] ) { $ blog = $ this -> repository -> store ( $ request -> all ( ) ) ; Cms :: notification ( 'Blog saved successfully.' , 'success' ) ; } else { return $ validat... | Store a newly created Blog in storage . |
50,318 | public function edit ( $ id ) { $ blog = $ this -> repository -> find ( $ id ) ; if ( empty ( $ blog ) ) { Cms :: notification ( 'Blog not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.blog.index' ) ) ; } return view ( 'cms::modules.blogs.edit' ) -> with ( 'blog' , $ blog ) ; } | Show the form for editing the specified Blog . |
50,319 | public function update ( $ id , BlogRequest $ request ) { $ blog = $ this -> repository -> find ( $ id ) ; if ( empty ( $ blog ) ) { Cms :: notification ( 'Blog not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.blog.index' ) ) ; } $ validation = app ( ValidationService :: class ) -> check ( B... | Update the specified Blog in storage . |
50,320 | public function history ( $ id ) { $ blog = $ this -> repository -> find ( $ id ) ; return view ( 'cms::modules.blogs.history' ) -> with ( 'blog' , $ blog ) ; } | Blog history . |
50,321 | public function show ( $ tag ) { $ images = $ this -> repository -> getImagesByTag ( $ tag ) -> paginate ( Config :: get ( 'cms.pagination' ) ) ; $ tags = $ this -> repository -> allTags ( ) ; if ( empty ( $ images ) ) { abort ( 404 ) ; } return view ( 'cms-frontend::gallery.show' ) -> with ( 'tags' , $ tags ) -> with ... | Display the specified Gallery . |
50,322 | public function paginated ( ) { $ model = $ this -> model ; if ( isset ( request ( ) -> dir ) && isset ( request ( ) -> field ) ) { $ model = $ model -> orderBy ( request ( ) -> field , request ( ) -> dir ) ; } else { $ model = $ model -> orderBy ( 'created_at' , 'desc' ) ; } return $ model -> paginate ( config ( 'cms.... | Returns all paginated items . |
50,323 | public function published ( ) { return $ this -> model -> where ( 'is_published' , 1 ) -> where ( 'published_at' , '<=' , Carbon :: now ( config ( 'app.timezone' ) ) -> format ( 'Y-m-d H:i:s' ) ) -> orderBy ( 'created_at' , 'desc' ) -> paginate ( config ( 'cms.pagination' , 24 ) ) ; } | Returns all published items . |
50,324 | public function arePublic ( ) { if ( Schema :: hasColumn ( $ this -> model -> getTable ( ) , 'is_published' ) ) { $ query = $ this -> model -> where ( 'is_published' , 1 ) ; if ( Schema :: hasColumn ( $ this -> model -> getTable ( ) , 'published_at' ) ) { $ query -> where ( 'published_at' , '<=' , Carbon :: now ( confi... | Returns all public items |
50,325 | public function search ( $ payload ) { $ query = $ this -> model -> orderBy ( 'created_at' , 'desc' ) ; $ query -> where ( 'id' , 'LIKE' , '%' . $ payload [ 'term' ] . '%' ) ; $ columns = Schema :: getColumnListing ( $ this -> table ) ; foreach ( $ columns as $ attribute ) { $ query -> orWhere ( $ attribute , 'LIKE' , ... | Search the columns of a given table |
50,326 | public function parseBlocks ( $ payload , $ module ) { $ blockCollection = [ ] ; foreach ( $ payload as $ key => $ value ) { if ( stristr ( $ key , 'block_' ) ) { $ blockName = str_replace ( 'block_' , '' , $ key ) ; $ blockCollection [ $ blockName ] = $ value ; unset ( $ payload [ $ key ] ) ; } } $ blockCollection = $... | Convert block payloads into json |
50,327 | public function parseTemplate ( $ payload , $ currentBlocks , $ module ) { if ( isset ( $ payload [ 'template' ] ) ) { $ content = file_get_contents ( base_path ( 'resources/themes/' . config ( 'cms.frontend-theme' ) . '/' . $ module . '/' . $ payload [ 'template' ] . '.blade.php' ) ) ; preg_match_all ( '/->block\((.*)... | Parse the template for blocks . |
50,328 | public function findEventsByDate ( $ date ) { return $ this -> model -> where ( 'is_published' , 1 ) -> where ( 'published_at' , '<=' , Carbon :: now ( config ( 'app.timezone' ) ) -> format ( 'Y-m-d H:i:s' ) ) -> orderBy ( 'created_at' , 'desc' ) -> where ( 'start_date' , '<=' , $ date ) -> where ( 'end_date' , '>=' , ... | Returns all published Events . |
50,329 | public function generate ( $ date = null ) { $ this -> date = $ date ; if ( is_null ( $ date ) ) { $ this -> date = date ( 'Y-m-d' ) ; } $ dateAsArray = explode ( '-' , $ this -> date ) ; $ today = Carbon :: createFromDate ( $ dateAsArray [ 0 ] , $ dateAsArray [ 1 ] , $ dateAsArray [ 2 ] ) ; foreach ( range ( 1 , $ tod... | Generate a calendar |
50,330 | public function calendar ( $ date ) { $ events = $ this -> eventRepository -> all ( ) ; $ dateArray = explode ( '-' , $ date ) ; $ daysInMonth = Carbon :: create ( $ dateArray [ 0 ] , $ dateArray [ 1 ] , $ dateArray [ 2 ] ) -> daysInMonth ; $ eventsByDate = [ ] ; foreach ( range ( 1 , $ daysInMonth ) as $ day ) { $ dat... | Get a calendar by date |
50,331 | public function asHtml ( $ config ) { $ class = $ config [ 'class' ] ; $ dates = $ config [ 'dates' ] ; $ daysOfTheWeek = [ 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' , 'Sunday' , ] ; $ output = '<table class="' . $ class . '">' ; $ output .= '<thead>' ; foreach ( $ daysOfTheWeek as $ day )... | Get a calendar as html |
50,332 | public function links ( $ class = null ) { if ( is_null ( $ class ) ) { $ class = '' ; } $ dateArray = explode ( '-' , $ this -> date ) ; $ previousMonth = Carbon :: create ( $ dateArray [ 0 ] , $ dateArray [ 1 ] , $ dateArray [ 2 ] ) -> subMonth ( ) -> toDateString ( ) ; $ nextMonth = Carbon :: create ( $ dateArray [ ... | Generate HTML links |
50,333 | public function index ( ) { $ result = $ this -> repository -> paginated ( ) ; return view ( 'cms::modules.files.index' ) -> with ( 'files' , $ result ) -> with ( 'pagination' , $ result -> render ( ) ) ; } | Display a listing of the Files . |
50,334 | public function update ( $ id , FileRequest $ request ) { $ files = $ this -> repository -> find ( $ id ) ; if ( empty ( $ files ) ) { Cms :: notification ( 'File not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.files.index' ) ) ; } $ files = $ this -> repository -> update ( $ files , $ requ... | Update the specified Files in storage . |
50,335 | public function destroy ( $ id ) { $ files = $ this -> repository -> find ( $ id ) ; if ( empty ( $ files ) ) { Cms :: notification ( 'File not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.files.index' ) ) ; } if ( is_file ( storage_path ( $ files -> location ) ) ) { Storage :: delete ( $ fi... | Remove the specified Files from storage . |
50,336 | public function update ( $ id , EventRequest $ request ) { $ event = $ this -> repository -> find ( $ id ) ; if ( empty ( $ event ) ) { Cms :: notification ( 'Event not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.events.index' ) ) ; } $ event = $ this -> repository -> update ( $ event , $ r... | Update the specified Event in storage . |
50,337 | public function store ( LinksRequest $ request ) { try { $ validation = app ( ValidationService :: class ) -> check ( Link :: $ rules ) ; if ( ! $ validation [ 'errors' ] ) { $ links = $ this -> repository -> store ( $ request -> all ( ) ) ; Cms :: notification ( 'Link saved successfully.' , 'success' ) ; if ( ! $ link... | Store a newly created Links in storage . |
50,338 | public function destroy ( $ id ) { $ link = $ this -> repository -> find ( $ id ) ; $ menu = $ link -> menu_id ; if ( empty ( $ link ) ) { Cms :: notification ( 'Link not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.menus.index' ) ) ; } $ order = json_decode ( $ link -> menu -> order ) ; $ k... | Remove the specified Links from storage . |
50,339 | public function tags ( $ tag ) { return $ this -> model -> where ( 'is_published' , 1 ) -> where ( 'published_at' , '<=' , Carbon :: now ( config ( 'app.timezone' ) ) -> format ( 'Y-m-d H:i:s' ) ) -> where ( 'tags' , 'LIKE' , '%' . $ tag . '%' ) -> orderBy ( 'created_at' , 'desc' ) -> paginate ( config ( 'cms.paginatio... | Blog tags with similar name |
50,340 | public function allTags ( ) { $ tags = [ ] ; if ( app ( ) -> getLocale ( ) !== config ( 'cms.default-language' , 'en' ) ) { $ blogs = $ this -> translationRepo -> getEntitiesByTypeAndLang ( app ( ) -> getLocale ( ) , 'Grafite\Cms\Models\Blog' ) ; } else { $ blogs = $ this -> model -> orderBy ( 'published_at' , 'desc' )... | Gets all tags of an entry |
50,341 | public function store ( $ payload ) { $ payload = $ this -> parseBlocks ( $ payload , 'blog' ) ; $ payload [ 'title' ] = htmlentities ( $ payload [ 'title' ] ) ; $ payload [ 'url' ] = Cms :: convertToURL ( $ payload [ 'url' ] ) ; $ payload [ 'is_published' ] = ( isset ( $ payload [ 'is_published' ] ) ) ? ( bool ) $ pay... | Stores Blog into database . |
50,342 | public function findBlogsByURL ( $ url ) { $ blog = null ; $ blog = $ this -> model -> where ( 'url' , $ url ) -> where ( 'is_published' , 1 ) -> where ( 'published_at' , '<=' , Carbon :: now ( config ( 'app.timezone' ) ) -> format ( 'Y-m-d H:i:s' ) ) -> first ( ) ; if ( ! $ blog ) { $ blog = $ this -> translationRepo ... | Find Blog by given URL . |
50,343 | public function update ( $ blog , $ payload ) { $ payload = $ this -> parseBlocks ( $ payload , 'blog' ) ; $ payload [ 'title' ] = htmlentities ( $ payload [ 'title' ] ) ; if ( isset ( $ payload [ 'hero_image' ] ) ) { app ( FileService :: class ) -> delete ( $ blog -> hero_image ) ; $ file = request ( ) -> file ( 'hero... | Updates Blog into database . |
50,344 | public function asPublic ( $ encFileName ) { try { return Cache :: remember ( $ encFileName . '_asPublic' , 3600 , function ( ) use ( $ encFileName ) { $ fileName = CryptoServiceFacade :: url_decode ( $ encFileName ) ; $ filePath = $ this -> getFilePath ( $ fileName ) ; $ fileTool = new SplFileInfo ( $ filePath ) ; $ e... | Provide the File as a Public Asset . |
50,345 | public function asPreview ( $ encFileName , Filesystem $ fileSystem ) { try { return Cache :: remember ( $ encFileName . '_preview' , 3600 , function ( ) use ( $ encFileName , $ fileSystem ) { $ fileName = CryptoServiceFacade :: url_decode ( $ encFileName ) ; if ( config ( 'cms.storage-location' ) === 'local' || config... | Provide the File as a Public Preview . |
50,346 | public function asDownload ( $ encFileName , $ encRealFileName ) { try { return Cache :: remember ( $ encFileName . '_asDownload' , 3600 , function ( ) use ( $ encFileName , $ encRealFileName ) { $ fileName = CryptoServiceFacade :: url_decode ( $ encFileName ) ; $ realFileName = CryptoServiceFacade :: url_decode ( $ en... | Provide file as download . |
50,347 | public function getMimeType ( $ extension ) { if ( isset ( $ this -> mimeTypes [ '.' . strtolower ( $ extension ) ] ) ) { return $ this -> mimeTypes [ '.' . strtolower ( $ extension ) ] ; } return 'text/plain' ; } | Get the mime type . |
50,348 | public function getFilePath ( $ fileName ) { if ( file_exists ( storage_path ( 'app/' . $ fileName ) ) ) { $ filePath = storage_path ( 'app/' . $ fileName ) ; } else { $ filePath = Storage :: disk ( config ( 'cms.storage-location' , 'local' ) ) -> url ( $ fileName ) ; } return $ filePath ; } | Get a file s path |
50,349 | public function getFileContent ( $ fileName , $ contentType , $ ext ) { if ( Storage :: disk ( config ( 'cms.storage-location' , 'local' ) ) -> exists ( $ fileName ) ) { $ fileContent = Storage :: disk ( config ( 'cms.storage-location' , 'local' ) ) -> get ( $ fileName ) ; } elseif ( ! is_null ( config ( 'filesystems.c... | Get a files content |
50,350 | public function index ( Request $ request ) { $ input = $ request -> all ( ) ; $ result = $ this -> repository -> paginated ( ) ; return view ( 'cms::modules.images.index' ) -> with ( 'images' , $ result ) -> with ( 'pagination' , $ result -> render ( ) ) ; } | Display a listing of the Images . |
50,351 | public function destroy ( $ id ) { $ image = $ this -> repository -> find ( $ id ) ; if ( is_file ( storage_path ( $ image -> location ) ) ) { Storage :: delete ( $ image -> location ) ; } else { Storage :: disk ( Config :: get ( 'cms.storage-location' , 'local' ) ) -> delete ( $ image -> location ) ; } if ( empty ( $ ... | Remove the specified Images from storage . |
50,352 | public function bulkDelete ( $ ids ) { $ ids = explode ( '-' , $ ids ) ; foreach ( $ ids as $ id ) { $ image = $ this -> repository -> find ( $ id ) ; if ( is_file ( storage_path ( $ image -> location ) ) ) { Storage :: delete ( $ image -> location ) ; } else { Storage :: disk ( Config :: get ( 'cms.storage-location' ,... | Bulk image delete |
50,353 | public function getFileClass ( $ file ) { $ sections = explode ( DIRECTORY_SEPARATOR , $ file ) ; $ fileName = $ sections [ count ( $ sections ) - 1 ] ; $ class = str_replace ( '.php' , '' , $ fileName ) ; return $ class ; } | Generate a name from the file path . |
50,354 | public function getModule ( ) { $ module = request ( ) -> segment ( 1 ) ; $ defaultModules = config ( 'cms.active-core-modules' ) ; $ extraModules = array_keys ( config ( 'cms.modules' , [ ] ) ) ; $ modules = array_merge ( $ defaultModules , $ extraModules ) ; if ( in_array ( $ module , $ modules ) ) { return str_singu... | Determine the module based on URL |
50,355 | public function moduleAsset ( $ module , $ path , $ contentType = 'null' ) { $ assetPath = base_path ( Config :: get ( 'cms.module-directory' ) . '/' . ucfirst ( $ module ) . '/Assets/' . $ path ) ; if ( ! is_file ( $ assetPath ) ) { $ assetPath = config ( 'cms.modules.' . $ module . '.asset_path' ) . '/' . $ path ; } ... | Module Assets . |
50,356 | public function moduleConfig ( $ module , $ path ) { $ configArray = @ include base_path ( Config :: get ( 'cms.module-directory' ) . '/' . ucfirst ( $ module ) . '/config.php' ) ; if ( ! $ configArray ) { return config ( 'cms.modules.' . $ module . '.' . $ path ) ; } return self :: assignArrayByPath ( $ configArray , ... | Module Config . |
50,357 | public function moduleLinks ( $ ignoredModules = [ ] , $ linkClass = 'nav-link' , $ listClass = 'nav-item' ) { $ links = '' ; $ modules = config ( 'cms.modules' , [ ] ) ; foreach ( $ ignoredModules as $ ignoredModule ) { if ( in_array ( strtolower ( $ ignoredModule ) , array_keys ( $ modules ) ) ) { unset ( $ modules [... | Module Links . |
50,358 | public function createOrUpdate ( $ entityId , $ entityType , $ lang , $ payload ) { $ translation = $ this -> model -> firstOrCreate ( [ 'entity_id' => $ entityId , 'entity_type' => $ entityType , 'language' => $ lang , ] ) ; unset ( $ payload [ '_method' ] ) ; unset ( $ payload [ '_token' ] ) ; $ translation -> entity... | Create or Update an entry |
50,359 | public function findByUrl ( $ url , $ type ) { $ item = $ this -> model -> where ( 'entity_type' , $ type ) -> where ( 'entity_data' , 'LIKE' , '%"url":"' . $ url . '"%' ) -> first ( ) ; if ( $ item && ( $ item -> data -> is_published == 1 || $ item -> data -> is_published == 'on' ) && $ item -> data -> published_at <=... | Find by URL |
50,360 | public function findByEntityId ( $ entityId , $ entityType ) { $ item = $ this -> model -> where ( 'entity_type' , $ entityType ) -> where ( 'entity_id' , $ entityId ) -> first ( ) ; if ( $ item && ( $ item -> data -> is_published == 1 || $ item -> data -> is_published == 'on' ) && $ item -> data -> published_at <= Car... | Find an entity by its Id |
50,361 | public function getEntitiesByTypeAndLang ( $ lang , $ type ) { $ entities = collect ( ) ; $ collection = $ this -> model -> where ( 'entity_type' , $ type ) -> where ( 'entity_data' , 'LIKE' , '%"lang":"' . $ lang . '"%' ) -> get ( ) ; foreach ( $ collection as $ item ) { $ instance = app ( $ item -> type ) -> attribut... | Get entities by type and language |
50,362 | public function getPagesAsOptions ( ) { $ pages = [ ] ; $ publishedPages = $ this -> repo -> all ( ) ; foreach ( $ publishedPages as $ page ) { $ pages [ $ page -> title ] = $ page -> id ; } return $ pages ; } | Get pages as options |
50,363 | public function getUrlAttribute ( ) { if ( $ this -> isLocalFile ( ) ) { return url ( str_replace ( 'public/' , 'storage/' , $ this -> location ) ) ; } elseif ( $ this -> fileExists ( ) ) { return $ this -> getS3Image ( ) ; } return $ this -> lostImage ( ) ; } | Get the images url location . |
50,364 | public function getS3Image ( ) { $ url = Storage :: disk ( Config :: get ( 'cms.storage-location' , 'local' ) ) -> url ( $ this -> location ) ; if ( ! is_null ( config ( 'cms.cloudfront' ) ) ) { $ url = str_replace ( config ( 'filesystems.disks.s3.bucket' ) . '.s3.' . config ( 'filesystems.disks.s3.region' ) . '.amazon... | Get an S3 image |
50,365 | public function remember ( $ attribute , $ closure ) { $ key = $ attribute . '_' . $ this -> location ; if ( ! Cache :: has ( $ key ) ) { $ result = $ closure ( ) ; Cache :: forever ( $ key , $ result ) ; } return Cache :: get ( $ key ) ; } | Simple caching tool |
50,366 | public function forgetCache ( ) { foreach ( [ 'url' , 'js_url' ] as $ attribute ) { $ key = $ attribute . '_' . $ this -> location ; Cache :: forget ( $ key ) ; } } | Forget the current Image caches |
50,367 | private function isLocalFile ( ) { try { if ( file_exists ( storage_path ( 'app/' . $ this -> location ) ) ) { return true ; } } catch ( Exception $ e ) { Log :: debug ( 'Could not find the image' ) ; return false ; } return false ; } | Check the location of the file . |
50,368 | public function lostImage ( ) { $ imagePath = app ( AssetService :: class ) -> generateImage ( 'File Not Found' ) ; $ image = InterventionImage :: make ( $ imagePath ) -> resize ( config ( 'cms.preview-image-size' , 800 ) , null , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; return ( string ) $ i... | Staged image if none are found |
50,369 | public function all ( ) { $ faqs = $ this -> repository -> published ( ) ; if ( empty ( $ faqs ) ) { abort ( 404 ) ; } return view ( 'cms-frontend::faqs.all' ) -> with ( 'faqs' , $ faqs ) ; } | Display all Faq entries . |
50,370 | public function update ( $ id , FAQRequest $ request ) { $ faq = $ this -> repository -> find ( $ id ) ; if ( empty ( $ faq ) ) { Cms :: notification ( 'FAQ not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.faqs.index' ) ) ; } $ validation = app ( ValidationService :: class ) -> check ( FAQ :... | Update the specified FAQ in storage . |
50,371 | public function destroy ( $ id ) { $ faq = $ this -> repository -> find ( $ id ) ; if ( empty ( $ faq ) ) { Cms :: notification ( 'FAQ not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.faqs.index' ) ) ; } $ faq -> delete ( ) ; Cms :: notification ( 'FAQ deleted successfully.' , 'success' ) ; ... | Remove the specified FAQ from storage . |
50,372 | public function update ( $ id , PagesRequest $ request ) { $ pages = $ this -> repository -> find ( $ id ) ; if ( empty ( $ pages ) ) { Cms :: notification ( 'Page not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.pages.index' ) ) ; } $ pages = $ this -> repository -> update ( $ pages , $ req... | Update the specified Pages in storage . |
50,373 | public function store ( Request $ request ) { try { $ validation = app ( ValidationService :: class ) -> check ( Menu :: $ rules ) ; if ( ! $ validation [ 'errors' ] ) { $ menu = $ this -> repository -> store ( $ request -> all ( ) ) ; Cms :: notification ( 'Menu saved successfully.' , 'success' ) ; if ( ! $ menu ) { C... | Store a newly created Menu in storage . |
50,374 | public function edit ( $ id ) { $ menu = $ this -> repository -> find ( $ id ) ; if ( empty ( $ menu ) ) { Cms :: notification ( 'Menu not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.menus.index' ) ) ; } $ links = $ this -> linkRepository -> getLinksByMenu ( $ menu -> id ) ; return view ( '... | Show the form for editing the specified Menu . |
50,375 | public function update ( $ id , MenuRequest $ request ) { try { $ menu = $ this -> repository -> find ( $ id ) ; if ( empty ( $ menu ) ) { Cms :: notification ( 'Menu not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.menus.index' ) ) ; } $ menu = $ this -> repository -> update ( $ menu , $ re... | Update the specified Menu in storage . |
50,376 | public function setOrder ( $ id , Request $ request ) { $ menu = $ this -> repository -> find ( $ id ) ; $ result = $ this -> repository -> setOrder ( $ menu , $ request -> except ( '_token' ) ) ; return app ( CmsResponseService :: class ) -> apiResponse ( 'success' , $ result ) ; } | Set the order |
50,377 | public function sortByKeys ( $ links , $ keys ) { if ( ! is_null ( $ keys ) ) { $ links = $ links -> keyBy ( 'id' ) ; $ sortedLinks = [ ] ; foreach ( $ keys as $ key ) { $ sortedLinks [ ] = $ links [ $ key ] ; } return collect ( $ sortedLinks ) ; } return $ links ; } | Sort by an existing set of keys |
50,378 | public function update ( $ id , WidgetRequest $ request ) { $ widgets = $ this -> repository -> find ( $ id ) ; if ( empty ( $ widgets ) ) { Cms :: notification ( 'Widgets not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.widgets.index' ) ) ; } $ widgets = $ this -> repository -> update ( $ w... | Update the specified Widgets in storage . |
50,379 | public function afterSaved ( $ payload ) { if ( ! request ( ) -> is ( 'cms/revert/*' ) && ! request ( ) -> is ( 'cms/rollback/*/*' ) ) { unset ( $ payload -> attributes [ 'created_at' ] ) ; unset ( $ payload -> attributes [ 'updated_at' ] ) ; unset ( $ payload -> original [ 'created_at' ] ) ; unset ( $ payload -> origi... | After the item is saved to the database . |
50,380 | public function beingDeleted ( $ payload ) { $ type = get_class ( $ payload ) ; $ id = $ payload -> id ; Translation :: where ( 'entity_id' , $ id ) -> where ( 'entity_type' , $ type ) -> delete ( ) ; Archive :: where ( 'entity_id' , $ id ) -> where ( 'entity_type' , $ type ) -> delete ( ) ; Archive :: where ( 'entity_... | When the item is being deleted . |
50,381 | public function findABlock ( $ slug ) { if ( isset ( $ this -> blocks [ $ slug ] ) ) { return $ this -> blocks [ $ slug ] ; } return false ; } | Find a block based on slug |
50,382 | public function getImagesByTag ( $ tag = null ) { $ images = $ this -> model -> orderBy ( 'created_at' , 'desc' ) -> where ( 'is_published' , 1 ) ; if ( ! is_null ( $ tag ) ) { $ images -> where ( 'tags' , 'LIKE' , '%' . $ tag . '%' ) ; } return $ images ; } | Returns all Images for the API . |
50,383 | public function allTags ( ) { $ tags = [ ] ; $ images = $ this -> model -> orderBy ( 'created_at' , 'desc' ) -> where ( 'is_published' , 1 ) -> get ( ) ; foreach ( $ images as $ image ) { foreach ( explode ( ',' , $ image -> tags ) as $ tag ) { if ( $ tag > '' ) { array_push ( $ tags , $ tag ) ; } } } return array_uniq... | Returns all Images tags . |
50,384 | public function show ( $ url ) { $ blog = $ this -> repository -> findBlogsByURL ( $ url ) ; if ( empty ( $ blog ) ) { abort ( 404 ) ; } return view ( 'cms-frontend::blog.' . $ blog -> template ) -> with ( 'blog' , $ blog ) ; } | Display the specified Blog . |
50,385 | public function apiErrorResponse ( $ errors , $ inputs ) { $ message = [ ] ; foreach ( $ inputs as $ key => $ value ) { if ( ! isset ( $ errors [ $ key ] ) ) { $ message [ $ key ] = [ 'status' => 'valid' , 'value' => $ value , ] ; } else { $ message [ $ key ] = [ 'status' => 'invalid' , 'error' => $ errors [ $ key ] , ... | Generate an API error response . |
50,386 | public function dropDeadFiles ( ) { @ unlink ( app_path ( 'Http/Controllers/PagesController.php' ) ) ; @ unlink ( app_path ( 'Http/Controllers/TeamController.php' ) ) ; @ unlink ( app_path ( 'Http/Requests/TeamCreateRequest.php' ) ) ; @ unlink ( app_path ( 'Http/Requests/TeamUpdateRequest.php' ) ) ; @ unlink ( app_path... | Clean up dead files . |
50,387 | public function store ( $ payload ) { $ result = false ; foreach ( $ payload [ 'location' ] as $ file ) { $ filePayload = $ payload ; $ filePayload [ 'name' ] = $ file [ 'original' ] ; $ filePayload [ 'location' ] = CryptoService :: decrypt ( $ file [ 'name' ] ) ; $ filePayload [ 'mime' ] = $ file [ 'mime' ] ; $ filePa... | Stores Files into database . |
50,388 | public function update ( $ files , $ payload ) { if ( isset ( $ payload [ 'location' ] ) ) { $ savedFile = app ( FileService :: class ) -> saveFile ( $ payload [ 'location' ] , 'files/' ) ; $ _file = $ payload [ 'location' ] ; $ filePayload = $ payload ; $ filePayload [ 'name' ] = $ savedFile [ 'original' ] ; $ filePay... | Updates Files into database . |
50,389 | public function apiPrepared ( ) { $ files = File :: orderBy ( 'created_at' , 'desc' ) -> where ( 'is_published' , 1 ) -> get ( ) ; $ allFiles = [ ] ; foreach ( $ files as $ file ) { array_push ( $ allFiles , [ 'file_identifier' => CryptoService :: url_encode ( $ file -> name ) . '/' . CryptoService :: url_encode ( $ fi... | Files output for API calls |
50,390 | public function makeTheProvider ( $ config , $ moduleDirectory , $ table ) { $ provider = file_get_contents ( __DIR__ . '/../Templates/CRUD/Provider.txt' ) ; foreach ( $ config as $ key => $ value ) { $ provider = str_replace ( $ key , $ value , $ provider ) ; } return file_put_contents ( $ moduleDirectory . '/' . ucfi... | Generate the provider file . |
50,391 | public function check ( $ form , $ jsonInput = false ) { $ result = [ ] ; $ errors = [ ] ; $ inputs = [ ] ; if ( is_array ( $ form ) ) { $ fields = $ form ; } else { $ conditions = Cms :: config ( 'validation.' . $ form ) ; $ fields = $ conditions ; } if ( ! is_array ( $ fields ) ) { $ fields = [ $ fields ] ; } $ valid... | Validation check . |
50,392 | public function errors ( $ format = 'array' ) { $ errorMessage = '' ; $ errors = Session :: get ( 'errors' ) ? : false ; if ( ! $ errors ) { return false ; } if ( $ format === 'string' ) { foreach ( $ errors as $ error => $ message ) { $ errorMessage .= $ message . '<br>' ; } } else { $ errorMessage = Session :: get ( ... | ValidationService Errors . |
50,393 | private function inputsArray ( $ jsonInput ) { if ( $ jsonInput ) { $ inputs = Input :: json ( ) ; } else { $ inputs = Input :: all ( ) ; unset ( $ inputs [ '_token' ] ) ; foreach ( $ inputs as $ key => $ value ) { if ( Input :: file ( $ key ) ) { unset ( $ inputs [ $ key ] ) ; } } } return $ inputs ; } | Get the inputs as an array . |
50,394 | protected function signUrl ( UrlImmutable $ url , $ expiration , $ signature ) { $ query = $ url -> getQuery ( ) ; $ query -> modify ( [ $ this -> expiresParameter => $ expiration , $ this -> signatureParameter => $ signature , ] ) ; $ urlSigner = $ url -> setQuery ( $ query ) ; return $ urlSigner ; } | Add expiration and signature query parameters to an url . |
50,395 | public function validate ( $ url ) { $ url = UrlImmutable :: createFromUrl ( $ url ) ; $ query = $ url -> getQuery ( ) ; if ( $ this -> isMissingAQueryParameter ( $ query ) ) { return false ; } $ expiration = $ query [ $ this -> expiresParameter ] ; if ( ! $ this -> isFuture ( $ expiration ) ) { return false ; } if ( !... | Validate a signed url . |
50,396 | protected function isMissingAQueryParameter ( QueryInterface $ query ) { if ( ! isset ( $ query [ $ this -> expiresParameter ] ) ) { return true ; } if ( ! isset ( $ query [ $ this -> signatureParameter ] ) ) { return true ; } return false ; } | Check if a query is missing a necessary parameter . |
50,397 | protected function getIntendedUrl ( UrlImmutable $ url ) { $ intendedQuery = $ url -> getQuery ( ) ; $ intendedQuery -> modify ( [ $ this -> expiresParameter => null , $ this -> signatureParameter => null , ] ) ; $ intendedUrl = $ url -> setQuery ( $ intendedQuery ) ; return $ intendedUrl ; } | Retrieve the intended URL by stripping off the UrlSigner specific parameters . |
50,398 | protected function getExpirationTimestamp ( $ expiration ) { if ( is_int ( $ expiration ) ) { $ expiration = ( new DateTime ( ) ) -> modify ( ( int ) $ expiration . ' days' ) ; } if ( ! $ expiration instanceof DateTime ) { throw new InvalidExpiration ( 'Expiration date must be an instance of DateTime or an integer' ) ;... | Retrieve the expiration timestamp for a link based on an absolute DateTime or a relative number of days . |
50,399 | protected function hasValidSignature ( UrlImmutable $ url ) { $ query = $ url -> getQuery ( ) ; $ expiration = $ query [ $ this -> expiresParameter ] ; $ providedSignature = $ query [ $ this -> signatureParameter ] ; $ intendedUrl = $ this -> getIntendedUrl ( $ url ) ; $ validSignature = $ this -> createSignature ( $ i... | Determine if the url has a forged signature . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.