Added contact page

This commit is contained in:
amikhaylov
2026-05-15 17:20:04 +03:00
parent 9e6b6c4dcb
commit 443a745029
13 changed files with 291 additions and 7 deletions
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers;
use App\Models\Managers\ContactManager;
class ContactsController extends Controller
{
public function __construct(
private ContactManager $contactManager
) {
$this->addCssFile('contacts.css');
}
public function index()
{
$contacts = $this->contactManager->getContacts();
return $this->render('contacts')
->with(compact('contacts'));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models\Loaders;
use App\Models\ORM\User;
class UsersLoader
{
public function getContacts(): array
{
$data = User::select(
"users.id","users.login","users.firstName","users.lastName",
"users.phone", "users.email", "users.vkcom as webPage",
"users.img_large","users.img_small","contactRoles.name as role"
)->join("contactRoles", "users.contactRole", "=", "contactRoles.id")
->where("users.useAsContact", 1)
->get();
return $data ? $data->toArray() : [];
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Models\Managers;
use App\Models\Loaders\UsersLoader;
use App\Models\Objects\Contact;
class ContactManager
{
private string $imgDir;
public function __construct(
private UsersLoader $usersLoader,
) {
$this->imgDir = config('directories.images');
}
public function getContacts(): array
{
$data = $this->usersLoader->getContacts();
$contacts = [];
foreach($data as $row) {
$contact = new Contact();
$contact->setImgPath($this->imgDir);
$contact->setAttributes($row);
$contacts[] = $contact;
}
return $contacts;
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models\ORM;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $primaryKey = 'id';
protected $table = 'users';
}
+141
View File
@@ -0,0 +1,141 @@
<?php
namespace App\Models\Objects;
class Contact
{
private ?int $id;
private string $login;
private string $firstName;
private string $lastName;
private string $phone;
private string $email;
private ?string $imgSmall;
private ?string $imgLarge;
private string $imgPath;
private ?string $webPage;
private ?string $role;
public function setImgPath(string $path): void
{
$this->imgPath = $path;
}
public function __construct(array $data = [])
{
if($data) {
$this->setAttributes($data);
}
}
public function getFullName(): string
{
return sprintf("%s %s", $this->firstName, $this->lastName);
}
public function toArray(): array
{
return [
'id' => $this->id,
'login' => $this->login,
'firstName' => $this->firstName,
'lastName' => $this->lastName,
'phone' => $this->phone,
'email' => $this->email,
'imgSmall' => $this->imgSmall,
'imgLarge' => $this->imgLarge,
'role' => $this->role,
];
}
public function setAttributes(array $attributes = []):void
{
$this->id = $attributes['id'] ?? null;
$this->login = $attributes['login'];
$this->firstName = $attributes['firstName'];
$this->lastName = $attributes['lastName'];
$this->phone = $attributes['phone'];
$this->email = $attributes['email'];
$this->webPage = $attributes['webPage'] ?? null;
$this->role = $attributes['role'] ?? null;
$this->imgSmall = $this->setImagePath($attributes['img_small']) ?? null;
$this->imgLarge = $this->setImagePath($attributes['img_large']) ?? null;
}
private function setImagePath(string $path = null): string
{
return $this->imgPath ?
$this->cleanURL($this->imgPath."/".$path) : $path;
}
private function cleanURL(string $url): string
{
return preg_replace('#(?<!:)/+#', '/', $url);
}
public function setImgSmall(string $imgSmall): void
{
$this->imgSmall = $imgSmall;
}
public function setImgLarge(string $imgLarge): void
{
$this->imgLarge = $imgLarge;
}
public function getId(): ?int
{
return $this->id;
}
public function getLogin(): string
{
return $this->login;
}
public function getFirstName(): string
{
return $this->firstName;
}
public function getLastName(): string
{
return $this->lastName;
}
public function getPhone(): string
{
return $this->phone;
}
public function getEmail(): string
{
return $this->email;
}
public function getImgSmall(): ?string
{
return $this->imgSmall;
}
public function getImgLarge(): ?string
{
return $this->imgLarge;
}
public function getImgPath(): string
{
return $this->imgPath;
}
public function getWebpage(): ?string
{
return $this->webPage;
}
public function getRole(): ?string
{
return $this->role;
}
}
?>
+4
View File
@@ -0,0 +1,4 @@
<?php
return [
'images' => "/img/contacts/"
];
+1 -1
View File
@@ -13,6 +13,6 @@ return [
"band" => [ "name"=>"Состав","url"=>"band","visible"=>1 ] "band" => [ "name"=>"Состав","url"=>"band","visible"=>1 ]
], ],
], ],
"media" => ["name"=>"Медиа","url"=>"media","visible"=> 1], "media" => ["name"=>"Медиа","url"=>"media","visible"=> 0],
"contacts" => ["name"=>"Контакты","url"=>"contacts","visible"=> 1] "contacts" => ["name"=>"Контакты","url"=>"contacts","visible"=> 1]
]; ];
+2 -1
View File
@@ -24,6 +24,7 @@
@section('breadcrump') @section('breadcrump')
<ol class="breadcrumb bread"> <ol class="breadcrumb bread">
<li>Группа / <a href="/band" class="breadcrumb-item">Состав</a></li> <li><a href="#" class="breadcrumb-item">Группа</a></li>
<li><a href="/band" class="breadcrumb-item">Состав</a></li>
</ol> </ol>
@endsection @endsection
+48
View File
@@ -0,0 +1,48 @@
@extends('main')
@section('title', 'Контакты')
@section('content')
<div class=container>
<div class="hidden-xs row emptyrow"></div>
<div class=row>
<div class="col-md-1 hidden-xs"></div>
@foreach($contacts as $contact)
<div class="col-sm-6 col-md-5">
<div class=contactBlock itemscope itemtype="http://data-vocabulary.org/Person">
<h3><span itemprop="title">{{ $contact->getRole() }}</span></h3>
<div class=contact>
<table class=contacts_table>
<tr id=contactName>
<td class="hidden-xs contactIcon" rowspan=4><img width=120 src='{{ $contact->getImgSmall() }}'></td>
<td id=contactFieldValue><span itemprop="name">{{ $contact->getFullName() }}</span></td>
</tr>
<tr id=contactPhone>
<td id=contactFieldValue><a href="tel:{{ $contact->getPhone() }}">{{ $contact->getPhone() }}</a></td>
</tr>
<tr id=contactEmail>
<td id=contactFieldValue>
<a target=blank href="mailto:{{ $contact->getEmail() }}">{{ $contact->getEmail() }}</a>
</td>
</tr>
<tr id=webPage>
<td id=contactFieldValue><a target=blank href='http://{{ $contact->getWebpage() }}'>
<span itemprop="url">{{ $contact->getWebpage() }}</span></a>
</td>
</tr>
</table>
</div>
</div>
</div>
@endforeach
</div>
<div class="hidden-xs row emptyrow"></div>
</div>
@endsection
@section('breadcrump')
<ol class="breadcrumb bread">
<li><a href="/contact" class="breadcrumb-item">Контакты</a></li>
</ol>
@endsection
+1 -1
View File
@@ -23,7 +23,7 @@
<div class="container transp"> <div class="container transp">
<div class="row">@include('include.menu')</div> <div class="row">@include('include.menu')</div>
<div class="row">@yield('content')</div> <div class="row">@yield('content')</div>
<div class=row>@include('include.footer')</div>content <div class=row>@include('include.footer')</div>
</div> </div>
@foreach($js_files as $js) @foreach($js_files as $js)
<script type="text/javascript" src="js/{{ $js }}"></script> <script type="text/javascript" src="js/{{ $js }}"></script>
+2 -1
View File
@@ -55,6 +55,7 @@
@section('breadcrump') @section('breadcrump')
<ol class="breadcrumb bread"> <ol class="breadcrumb bread">
<li><a href="/band/playlist" class="breadcrumb-item">Группа / Репертуар</a></li> <li><a href="#" class="breadcrumb-item">Группа</a></li>
<li><a href="/playlist" class="breadcrumb-item">Репертуар</a></li>
</ol> </ol>
@endsection @endsection
+2 -1
View File
@@ -88,6 +88,7 @@
@section('breadcrump') @section('breadcrump')
<ol class="breadcrumb bread"> <ol class="breadcrumb bread">
<li><a href="main" class="breadcrumb-item">Группа / Райдер</a></li> <li><a href="#" class="breadcrumb-item">Группа</a></li>
<li><a href="/rider" class="breadcrumb-item">Репертуар</a></li>
</ol> </ol>
@endsection @endsection
+4 -2
View File
@@ -7,6 +7,7 @@ use App\Http\Controllers\PlaylistController;
use App\Http\Controllers\BandController; use App\Http\Controllers\BandController;
use App\Http\Controllers\GigsController; use App\Http\Controllers\GigsController;
use App\Http\Controllers\NewsController; use App\Http\Controllers\NewsController;
use App\Http\Controllers\ContactsController;
Route::get('/', [MainController::class, 'index']); Route::get('/', [MainController::class, 'index']);
Route::get('/rider', [RiderController::class, 'index']); Route::get('/rider', [RiderController::class, 'index']);
@@ -14,8 +15,9 @@ Route::get('/playlist', [PlaylistController::class, 'index']);
Route::get('/band', [BandController::class, 'index']); Route::get('/band', [BandController::class, 'index']);
Route::get('/gigs', [GigsController::class, 'index']); Route::get('/gigs', [GigsController::class, 'index']);
Route::get('/news', [NewsController::class, 'index']); Route::get('/news', [NewsController::class, 'index']);
Route::get('/contacts', [ContactsController::class, 'index']);
/** /**
* Доделать остальные маршруты * Доделать остальные маршруты..
* и сотальные страницы требуют ...
*/ */