Issues (25)

application/models/Media/Table.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
declare(strict_types=1);
8
9
namespace Application\Media;
10
11
use Application\Exception;
0 ignored issues
show
The type Application\Exception was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Bluz\Proxy\Auth;
13
14
/**
15
 * Table
16
 *
17
 * @package  Application\Media
18
 *
19
 * @method   static Row findRow($primaryKey)
20
 * @method   static Row findRowWhere($whereList)
21
 */
22
class Table extends \Bluz\Db\Table
23
{
24
    /**
25
     * Table
26
     *
27
     * @var string
28
     */
29
    protected $name = 'media';
30
31
    /**
32
     * Primary key(s)
33
     * @var array
34
     */
35
    protected $primary = ['id'];
36
37
    /**
38
     * Get images of current user
39
     *
40
     * @return Row[]
41
     * @throws Exception
42
     */
43
    public function getImages()
44
    {
45
        /* @var \Application\Users\Row $user */
46
        if (!$user = Auth::getIdentity()) {
47
            throw new Exception('User not found');
48
        }
49
50
        return $this->getImagesByUserId($user->getId());
51
    }
52
53
    /**
54
     * Get images by owner
55
     *
56
     * @param  integer $id
57
     * @return Row[]
58
     */
59
    public function getImagesByUserId($id)
60
    {
61
        return self::select()
62
            ->where('type LIKE (?)', 'image/%')
63
            ->andWhere('userId = ?', $id)
64
            ->execute();
65
    }
66
}
67