Develop Notifikasi
This commit is contained in:
@@ -7,6 +7,8 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use View;
|
||||
use App\Models\Notifikasi;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
@@ -25,4 +27,27 @@ class Controller extends BaseController
|
||||
View::share ( 'sitesubTitle' , $name );
|
||||
}
|
||||
|
||||
public function sendNotif($roleFrom, $roleTo, $userId=[], $message, $url, $jenis, $unik)
|
||||
{
|
||||
foreach($userId as $rowUserId){
|
||||
$notif = new Notifikasi;
|
||||
$notif["role_from"]=$roleFrom;
|
||||
$notif["role_to"]=$roleTo;
|
||||
$notif["userid"]=$rowUserId;
|
||||
$notif["message"]=$message;
|
||||
$notif["url"]=$url;
|
||||
$notif["is_read"]=0;
|
||||
$notif["jenis"]=$jenis;
|
||||
$notif["id_unik"]=$unik;
|
||||
$notif->save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function readNotif($idUnik)
|
||||
{
|
||||
$notif = Notifikasi::where(["id_unik"=>$idUnik, "userid"=>Auth::user()->id])->firstOrNew();
|
||||
$notif->update(["is_read"=>1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user