I am using database notifications in Laravel 5.3. Is there a function or property to check if the notification is read or not when looping through the user's notifications. Thanks in advance
You can sure can.
There are in fact two methods available in Laravel to check whether notifications
read
unread
So you can do something like this in your Blade template:
#foreach(auth()->user()->notifications as $notification)
...
#if($notification->unread())<badge>#lang('app.new')</badge>#endif
...
#endforeach
You can also query Notification collection with these methods.
In the newer versions of laravel (6.2+), you can get all, read or unread notifications as collection. So, to get all read notifications, you can do something like:
#foreach (Auth::user()->readNotifications as $notification)
// process $notification
#endforeach
You can take unreaded and readed notification seperately if you want
$unreadedNotifications = Auth::user()->unreadNotifications();
if($unreadedNotifications->count() > 0){}
$readedNotifications = Auth::user()->readNotifications()->get();
if($readedNotifications->count() > 0){}
Related
Is it possible using the web extensions API to get the default download folder for the current profile? I need to send it via native messaging to an external app.
I feel like https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads should have it but it does't seem to.
Your best bet is probably making a dummy download and sending the "filename" property that you get back as a variable to your external app.
You would use the browser.downloads.onChanged event to get a reference to the filename value:
browser.downloads.onChanged.addListener(listener);
function listener(changed){
if(changed.filename != null){
// Do something
// Remove downloads.onChanged listener
browser.downloads.onChanged.removeListener(listener);
}
}
browser.downloads.download({url: dummyUrl});
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads/onChanged
I have an Ionic App and I'd like to put a "Remember me" checkbox in the login page, so that once the user has logged in he'll be logged in forever (unless he logouts), even if he close and re-opens the application, just as the Facebook app does.
Is there a way to do that in Ionic 2?
Thanks!
You can use localstorage to save some data for your own verification/logic handling.It's html5 supported and easy to use. The downside would be it won't be secure and it might be erased by system when there's low memory or clearing of cache.
HTML(Upon button press, but u can set it to your own preference):
<button secondary (click)="addLocalStorage()">Done</button>
In your controller:
import {Storage, LocalStorage} from 'ionic-angular';
constructor(navController, local) {
this.navController = navController;
this.local = new Storage(LocalStorage);
}
addLocalStorage(){
this.local.set("didTutorial","true");
//set the doneTutorial to be true
}
Explanation:
At the constructor , we create an new localstorage object called 'local'.
To call it, we use 'this.local' and 'set' is the method to store it.
Set(Key,Value)
In the example code above, i use 'didTutorial' as the key and 'true' as the value.
To retrieve it, you can retrieve it at this page or at any other page.
Just remember to import Storage and LocalStorage and declare a new localstorage object in the constructor.(same as above)
The code to retrieve is :
var value = localStorage.getItem('didTutorial');
getitem(Key,Value)
You can use storage and sqlStorage to save user data. And then check it for saved user.
Refer :-
https://www.thepolyglotdeveloper.com/2015/12/use-sqlite-in-ionic-2-instead-of-local-storage/
Hope this helps!
localStorage works fine but I confirm the drawbacks that #Gene talks about. It is not reliable, especially on iPhones that do not have much free storage
I use ionic 1 so I cannot try this solution, but you might want to check this out : https://ionicframework.com/docs/native/native-storage/
; could be more reliable!
I want to send a WhatsApp message to a specific contact with the Automate-app. How can do I do this?
This is the link to the app:
https://play.google.com/store/apps/details?id=com.llamalab.automate
I know this is pretty late reply.
You can make use of below blocks and build
App start block and choose activity class as
com.whatsapp.ContactPicker
Use Interact blocks for searching, selecting and messaging
Extend with Variable for searching contact and for message text
I have been trying different ways but many of them fall short of full automation.
currently, I am using blocks to send a message to (unsaved) contact. This skips the contactPicker window.
the flow blocks:
[start flow] --> [view content] --> [interact]
that's it!
in view content, you will need to specify the content uri (change number and msg):
https://api.whatsapp.com/send?phone=+966xxxxxxxxx&text=msg
in interact block, specify the (proceed) when element appeared.
the (action) is click.
and (XPATH):
fn:reverse((.//[{("android.widget.ImageButton") = null ? "true()" : "fn:choose(#class,string(#class),name())={"android.widget.ImageButton";xpathEncode}"} and {("com.whatsapp:id/send") = null ? "true()" : "#android:id={"#" ++ ("com.whatsapp:id/send");xpathEncode}"}])[1]/ancestor-or-self::)
that's it.
I've successfully implemented push notifications with RavenDB (see code below). I was expecting the actual document to be included with the change notification. That way, all the UI clients can display the information. However, it seems that only the Id and Etag properties are available for the changed document.
What am I supposed to do if I want the client to be able to display information about the document? Does the client now need to make a DB call to get the document based on the ID? It seems inefficient to have to make a DB call to get the information. But, is that what is supposed to happen?
documentStore.Changes()
.ForDocumentsStartingWith("LogMessages")
.Subscribe(change =>
{
if (change.Type == DocumentChangeTypes.Put)
{
// Fire event so consumers can display document info
// Uh oh, are change.Id and change.Etag all we have here?
DatabaseItemAdded(null, new EventArgs<string>(change.Id));
}
});
Yes, you need to call the db to get the new document.
The reason for that is that it would be expensive to send the document (which may be very big) if all you need is just the notification on the change).
Is there any way to force a Kaltura videoplayer to stop ONLY using code and the Kaltura API?
Currently I have solved it by adding a Access Control Profile named "Free preview" under Settings > Access Control in KMC and then added this profile to the Entries I've choosen.
I then add the session to the players flashvars to restrict non-members to only watch the preview, not the whole clip.
But I would like to restrict ALL, or even better selected Categories of clips by using only code, so I don't need to involve KMC.
Is that possible?
Alt) Can you create a new player in KMC and restrict it to viewing only X seconds, no matter what length of Entry? Then I can do the check if user is valid or not and get the category via API and show it in the "preview-player" och the "default player".
If I use the mediaProxy.mediaPlayTo attribute the clip stops, but is easily started again by presing play.
Would greatly appreciate an answer
I got this answer from a guy named oferc in a different forum:
You can listen to the head move event and pause the clip it goes beyond a certain time (then if someone pressed play, you can stop it again)
function jsCallbackReady(player_id) {
my_kdp = $("#"+player_id).get(0); // document.getElementById(player_id) if you do not use jquery/ prefer pure js
my_kdp.addJsListener("kdpReady", "kdpReady"); // when you load the player with an entry (and the player is ready to begin playing it using doPlay for instance)
}
function kdpReady() {
my_kdp.addJsListener("playerUpdatePlayhead","headMove");
}
function headMove(position) {
if (position > "30") { // Your Time, example 30 seconds
my_kdp.sendNotification('doStop')
}
}
Works like a charm!
fredrik_w - neither of the ways you chosen here are a good option to restrict access.
in both cases, your videos are made public, and can be easily accessible by anyone.
The best way to limit access to a video is by defining an Access Control, and like everything in Kaltura, you can define an ACL using API as well.
Check this out as a reference sample-
http://blog.kaltura.org/turning-profit-online-video-made-easy-using-paypal-html5-digital-goods