mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-01-12 01:18:40 +00:00
77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.1
|
|
*
|
|
* @category TBD
|
|
* @package TBD
|
|
* @author OMS Development Team <dev@oms.com>
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://orange-management.com
|
|
*/
|
|
declare(strict_types=1);
|
|
namespace Modules\Media\Models;
|
|
|
|
use Modules\Media\Models\MediaMapper;
|
|
use phpOMS\DataStorage\Database\Query\Builder;
|
|
use phpOMS\DataStorage\Database\Query\Column;
|
|
|
|
class CollectionMapper extends MediaMapper
|
|
{
|
|
protected static $hasMany = [
|
|
'sources' => [
|
|
'mapper' => MediaMapper::class, /* mapper of the related object */
|
|
'table' => 'media_relation', /* table of the related object, null if no relation table is used (many->1) */
|
|
'dst' => 'media_relation_dst',
|
|
'src' => 'media_relation_src',
|
|
],
|
|
];
|
|
|
|
/**
|
|
* Primary table.
|
|
*
|
|
* @var string
|
|
* @since 1.0.0
|
|
*/
|
|
protected static $table = 'media';
|
|
|
|
/**
|
|
* Created at.
|
|
*
|
|
* @var string
|
|
* @since 1.0.0
|
|
*/
|
|
protected static $createdAt = 'media_created_at';
|
|
|
|
/**
|
|
* Primary field name.
|
|
*
|
|
* @var string
|
|
* @since 1.0.0
|
|
*/
|
|
protected static $primaryField = 'media_id';
|
|
|
|
/**
|
|
* Find.
|
|
*
|
|
* @param array $columns Columns to select
|
|
*
|
|
* @return Builder
|
|
*
|
|
* @since 1.0.0
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
*/
|
|
public static function find(...$columns) : Builder
|
|
{
|
|
return parent::find(...$columns)->from('account_permission')
|
|
->where('account_permission.account_permission_for', '=', 'news')
|
|
->where('account_permission.account_permission_id1', '=', 1)
|
|
->where('news.news_id', '=', new Column('account_permission.account_permission_id2'))
|
|
->where('account_permission.account_permission_r', '=', 1);
|
|
}
|
|
}
|