Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Front/default/profile/log.php (1 issue)

Labels
Severity
1
<?php
2
3
use Ffcms\Core\Helper\Date;
4
use Ffcms\Templex\Url\Url;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Url. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
5
6
/** @var \Ffcms\Templex\Template\Template $this */
7
/** @var Apps\ActiveRecord\UserLog[]|\Illuminate\Support\Collection $records */
8
/** @var array $pagination */
9
10
$this->layout('_layouts/default', [
11
    'title' => __('Logs'),
12
    'breadcrumbs' => [
13
        Url::to('main/index') => __('Home'),
14
        Url::to('profile/show', [\App::$User->identity()->getId()]) => __('Profile'),
15
        __('Logs')
16
    ]
17
]);
18
?>
19
20
<?php $this->start('body') ?>
21
22
<?php $this->insert('profile/menus/settings') ?>
23
24
<h2><?= __('My logs') ?></h2>
25
<hr />
26
<?php if(!$records || $records->count() < 1) {
27
    echo $this->bootstrap()->alert('info', __('No logs available'));
28
    $this->stop();
29
    return;
30
} ?>
31
<div class="table-responsive">
32
<?php
33
    $table = $this->table(['class' => 'table'])
34
        ->head([
35
            ['text' => '#'],
36
            ['text' => __('Type')],
37
            ['text' => __('Message')],
38
            ['text' => __('Date')]
39
        ]);
40
    foreach ($records as $log) {
41
        $table->row([
42
            ['type' => 'text', 'text' => $log->id],
43
            ['type' => 'text', 'text' => $log->type],
44
            ['type' => 'text', 'text' => $log->message],
45
            ['type' => 'text', 'text' => Date::convertToDatetime($log->created_at, Date::FORMAT_TO_HOUR)]
46
        ]);
47
    }
48
    echo $table->display();
49
?>
50
</div>
51
52
<?= $this->bootstrap()->pagination(['profile/log'], ['class' => 'pagination justify-content-center'])
53
    ->size($pagination['total'], $pagination['page'], $pagination['step'])
54
    ->display()
55
?>
56
57
<?php $this->stop() ?>