Passed
Push — master ( c1ca83...c6150b )
by Mihail
04:57
created

Apps/View/Admin/default/profile/index.php (1 issue)

Labels
Severity
1
<?php
2
3
use Ffcms\Core\Helper\Type\Str;
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
use Ffcms\Core\Helper\Date;
6
7
/** @var \Apps\ActiveRecord\Profile[]|\Illuminate\Support\Collection $records */
8
/** @var array $pagination */
9
/** @var \Ffcms\Templex\Template\Template $this */
10
11
$this->layout('_layouts/default', [
12
    'title' => __('Profile list'),
13
    'breadcrumbs' => [
14
        Url::to('main/index') => __('Main'),
15
        Url::to('application/index') => __('Applications'),
16
        __('Profile')
17
    ]
18
]);
19
?>
20
21
<?php $this->start('body') ?>
22
23
<?= $this->insert('profile/_tabs') ?>
24
25
<h1><?= __('Profile list') ?></h1>
26
<?php
27
$table = $this->table(['class' => 'table table-striped'])
28
    ->head([
29
        ['text' => '#'],
30
        ['text' => 'login'],
31
        ['text' => 'email'],
32
        ['text' => __('Nickname')],
33
        ['text' => __('Birthday')],
34
        ['text' => __('Rating')],
35
        ['text' => __('Actions'), 'properties' => ['class' => 'text-center']]
36
    ]);
37
38
foreach ($records as $profile) {
39
    $table->row([
40
        ['text' => $profile->id],
41
        ['text' => $profile->user->login],
42
        ['text' => $profile->user->email],
43
        ['text' => $profile->nick],
44
        ['text' => Str::startsWith('0000-', $profile->birthday) ? __('None') : Date::convertToDatetime($profile->birthday)],
45
        ['text' => ($profile->rating > 0 ? '+' : null) . $profile->rating],
46
        ['text' => $this->bootstrap()->btngroup(['class' => 'btn-group btn-group-sm'])
47
            ->add('<i class="fa fa-pencil"></i>', ['profile/update', [$profile->id]], ['html' => true, 'class' => 'btn btn-primary'])
48
            ->add('<i class="fa fa-trash-o"></i>', ['user/delete', [$profile->user->id]], ['html' => true, 'class' => 'btn btn-danger'])
49
            ->display(), 'html' => true, 'properties' => ['class' => 'text-center']]
50
    ]);
51
}
52
?>
53
54
<div class="table-responsive">
55
    <?= $table->display() ?>
56
</div>
57
58
<?= $this->bootstrap()->pagination($pagination['url'], ['class' => 'pagination justify-content-center'])
59
    ->size($pagination['total'], $pagination['page'], $pagination['step'])
60
    ->display(); ?>
61
62
<?php $this->stop() ?>