Last active
January 12, 2020 12:27
-
-
Save msacar/068b5a6843b59d4859e2863a9b3764f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Jenssegers\Mongodb\Eloquent\Model; | |
class MongoNotification extends Model | |
{ | |
protected $connection = "mongodb"; | |
protected $table = "notifications"; | |
protected $guarded = []; | |
/** | |
* Notifikasyonu okunmuş olarak işaretler. | |
* | |
* @return void | |
*/ | |
public function markAsRead() | |
{ | |
if (is_null($this->read_at)) { | |
$this->forceFill([ 'read_at' => $this->freshTimestamp() ])->save(); | |
} | |
} | |
/** | |
* Notifikasyonu okunmamış olarak işaretler. | |
* | |
* @return void | |
*/ | |
public function markAsUnread() | |
{ | |
if (!is_null($this->read_at)) { | |
$this->forceFill([ 'read_at' => null ])->save(); | |
} | |
} | |
/** | |
* Notifikasyonun okunmuş olduğunu kontrol eder. | |
* | |
* @return bool | |
*/ | |
public function isRead() | |
{ | |
return $this->read_at !== null; | |
} | |
/** | |
* Notifikasyonun okunmamış olduğunu kontrol eder | |
* | |
* @return bool | |
*/ | |
public function isUnread() | |
{ | |
return $this->read_at === null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment