-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Web\Search; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\User; | ||
use Illuminate\Http\Request; | ||
|
||
class SearchController extends Controller | ||
{ | ||
public function search(Request $request) { | ||
$query = $request->get('q'); | ||
|
||
if(!$query || strlen($query) < 1 || strlen($query) > 255) return redirect('/'); | ||
|
||
$data = User::where('username', 'like', "%$query%") | ||
->orWhere('name', 'like', "%$query%") | ||
->limit(30)->get(); | ||
|
||
return view('pages/other/search', compact('data'), ['query' => $query]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
new Tabs( | ||
[ | ||
if(window.location.pathname === '/profile') { | ||
new Tabs( | ||
[ | ||
{ | ||
id: 'main', | ||
triggerEl: document.querySelector('#main_tab-tab'), | ||
targetEl: document.querySelector('#main_tab') | ||
}, | ||
{ | ||
id: 'follows', | ||
triggerEl: document.querySelector('#follows_tab-tab'), | ||
targetEl: document.querySelector('#follows_tab') | ||
}, | ||
{ | ||
id: 'followers', | ||
triggerEl: document.querySelector('#followers_tab-tab'), | ||
targetEl: document.querySelector('#followers_tab') | ||
}, | ||
], | ||
{ | ||
id: 'main', | ||
triggerEl: document.querySelector('#main_tab-tab'), | ||
targetEl: document.querySelector('#main_tab') | ||
}, | ||
{ | ||
id: 'follows', | ||
triggerEl: document.querySelector('#follows_tab-tab'), | ||
targetEl: document.querySelector('#follows_tab') | ||
}, | ||
{ | ||
id: 'followers', | ||
triggerEl: document.querySelector('#followers_tab-tab'), | ||
targetEl: document.querySelector('#followers_tab') | ||
}, | ||
], | ||
{ | ||
defaultTabId: 'follows', | ||
activeClasses: 'border-b-4 dark:border-cyan-300', | ||
inactiveClasses: '_', | ||
} | ||
); | ||
|
||
defaultTabId: 'main', | ||
activeClasses: 'border-b-4 dark:border-cyan-300', | ||
inactiveClasses: '_', | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
<div class="flex items-center justify-between w-full mb-6"> | ||
<div class="flex items-center"> | ||
@if($user->avatar) | ||
<img alt="avatar" class="w-24 h-24 rounded-full mr-4" src="{{$user->getAvatarLink()}}"> | ||
@if($u->avatar) | ||
<img alt="avatar" class="w-24 h-24 rounded-full mr-4" src="{{$u->getAvatarLink()}}"> | ||
@else | ||
<img alt="avatar" class="w-24 h-24 rounded-full mr-4" src="{{asset('img/default/default-avatar.svg')}}"> | ||
@endif | ||
<div class="flex flex-col items-start justify-center"> | ||
<h5 class="font-bold text-xl">{{$user->name}}</h5> | ||
<span class="text-slate-500 text-base">{{"@$user->username"}}</span> | ||
<h5 class="font-bold text-xl">{{$u->name}}</h5> | ||
<span class="text-slate-500 text-base">{{"@$u->username"}}</span> | ||
</div> | ||
</div> | ||
<form data-follow-form action="/profile/{{$user->username}}/follow" method="POST" class="justify-self-end"> | ||
@if($isFollowing) | ||
<button type="submit" class="px-4 py-2 font-medium text-sm text-white rounded-full shadow-sm bg-transparent border border-slate-500 hover:bg-slate-800">Отписаться</button> | ||
@else | ||
<button type="submit" class="px-4 py-2 font-medium text-sm text-white rounded-full shadow-sm bg-cyan-600 hover:bg-cyan-700">Подписаться</button> | ||
@endif | ||
</form> | ||
@if(auth()->user()->isNot($u)) | ||
<form data-follow-form action="/profile/{{$u->username}}/follow" method="POST" class="justify-self-end"> | ||
@if($isFollowing) | ||
<button type="submit" class="px-4 py-2 font-medium text-sm text-white rounded-full shadow-sm bg-transparent border border-slate-500 hover:bg-slate-800">Отписаться</button> | ||
@else | ||
<button type="submit" class="px-4 py-2 font-medium text-sm text-white rounded-full shadow-sm bg-cyan-600 hover:bg-cyan-700">Подписаться</button> | ||
@endif | ||
</form> | ||
@endif | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@extends('layouts/default') | ||
|
||
@section('title', 'Поиск') | ||
|
||
@section('content') | ||
<div class="flex flex-col items-center pt-4"> | ||
<div class="px-8 mb-4 self-start"> | ||
<h1 class="text-xl font-bold">Результаты поиска: {{$query}}</h1> | ||
</div> | ||
<div class="flex flex-col w-full p-8"> | ||
@php $follows = auth()->user()->follows @endphp | ||
@forelse($data as $u) | ||
@php | ||
$isFollowing = $follows->contains($u); | ||
@endphp | ||
@include('includes/_follows-list' , ['isFollowing' => $isFollowing]) | ||
@empty | ||
<p class="self-center text-gray-300">Ничего не найдено</p> | ||
@endforelse | ||
</div> | ||
</div> | ||
@endsection | ||
|
||
@section('scripts') | ||
|
||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters