mirror of
https://github.com/flarum/core.git
synced 2025-10-11 23:14:29 +02:00
Implement notifications
This commit is contained in:
@@ -15,4 +15,9 @@ class Actor
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function isAuthenticated()
|
||||
{
|
||||
return (bool) $this->user;
|
||||
}
|
||||
}
|
||||
|
43
src/Core/Support/MappedMorphTo.php
Normal file
43
src/Core/Support/MappedMorphTo.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php namespace Flarum\Core\Support;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MappedMorphTo extends MorphTo {
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $types;
|
||||
|
||||
/**
|
||||
* Create a new morph to relationship instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param \Illuminate\Database\Eloquent\Model $parent
|
||||
* @param string $foreignKey
|
||||
* @param string $otherKey
|
||||
* @param string $type
|
||||
* @param string $relation
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Builder $query, Model $parent, $foreignKey, $otherKey, $type, $relation, $types)
|
||||
{
|
||||
$this->types = $types;
|
||||
|
||||
parent::__construct($query, $parent, $foreignKey, $otherKey, $type, $relation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new model instance by type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function createModelByType($type)
|
||||
{
|
||||
return new $this->types[$type];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user