# General

## Meta & Logo

-   Example usage +

    ```php
    <title>@yield('title'){{ get_site_title() }}</title>
    <meta name="description" content="@yield('description'){{ get_site_description() }}">
    <meta name="keywords" content="{{ get_site_keywords() }}">
    <!-- Favicon -->
    <link rel="shortcut icon" href="{{ get_site_favicon() }}" type="image/x-icon" />
    <link rel="apple-touch-icon" href="{{ get_site_favicon() }}">
    ```

<!-- panels:start -->
<!-- div:title-panel -->

### Site Title

<!-- div:left-panel -->

Get site title.

?> **Response Type:** Illuminate\Support\Str<br>
**Response Content:** Site Title

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_site_title()
```

#### **Example**

```php
<title>@yield('title'){{ get_site_title() }}</title>
```

#### **Inspect**

```php
function get_site_title()
{
    $query = get_site_settings()->site_name ?? env('APP_NAME') ?? '';
    return $query;
}
```

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Site Description

<!-- div:left-panel -->

Get site description.

?> **Response Type:** Illuminate\Support\Str<br>
**Response Content:** Site Description

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_site_description()
```

#### **Example**

```php
<meta name="description" content="@yield('description'){{ get_site_description() }}">
```

#### **Inspect**

```php
function get_site_descipriton()
{
    $query = Settings::where('language_id', get_language_id())->first();
    return $query->site_description ?? '';
}
```

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Site Keywords

<!-- div:left-panel -->

Get site keywords.

?> **Response Type:** Illuminate\Support\Str<br>
**Response Content:** Site Keywords

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_site_keywords()
```

#### **Example**

```php
<meta name="keywords" content="{{ get_site_keywords() }}">
```

#### **Inspect**

```php
function get_site_keywords()
{
    return (Site::site_settings()->site_keywords ?? '');
}
```

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Site Logo

<!-- div:left-panel -->

Get site logo.

> [!NOTE] > **Parameters**<br>
>
> -   **type**
>     -   **Type:** string
>     -   **Default:** dark
>     -   **Required:** false

?> **Response Type:** Illuminate\Support\Str<br>
**Response Content:** Site Logo Path

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_site_logo($type = "dark")
```

#### **Example**

```php
<img src="{{ get_site_logo('light') }}" alt="{{ get_site_title() }}" height="120">
```

#### **Inspect**

```php
function get_site_logo($type = "dark")
{
    $logo = SiteSetting::where('key', 'logo_' . $type)->first()->value ?? 'logo.png';

    $asset_path = 'uploads/logo/' . $logo;
    $path = public_path($asset_path);
    if (file_exists($path)) {
        return asset($asset_path) . "?v=" . date('Y-m-d-H:i');
    }
    return asset('/images/logo-icon.png');
}
```

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Site Favicon

<!-- div:left-panel -->

Get site favicon.

?> **Response Type:** Illuminate\Support\Str<br>
**Response Content:** Site Favicon Path

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_site_favicon()
```

#### **Example**

```php
<!-- Favicon -->
<link rel="shortcut icon" href="{{ get_site_favicon() }}" type="image/x-icon" />
<link rel="apple-touch-icon" href="{{ get_site_favicon() }}">
```

#### **Inspect**

```php
function get_site_favicon()
{
    $logo = SiteSetting::where('key', 'favicon')->first()->value ?? 'logo.png';

    $asset_path = 'uploads/logo/' . $logo;
    $path = public_path($asset_path);
    if (file_exists($path)) {
        return asset($asset_path) . "?v=" . date('Y-m-d-H:i');
    }
    return asset('/images/logo-icon.png');
}
```

<!-- tabs:end -->
<!-- panels:end -->

---

## Site Settings

The codes written in this section may be useful when you need to keep any configuration on the site.

<!-- panels:start -->
<!-- div:title-panel -->

### Get By Key

<!-- div:left-panel -->

Get site settings by key.

> [!NOTE] > **Parameters**<br>
>
> -   **key**
>     -   **Type:** string
>     -   **Default:** -
>     -   **Required:** true

?> **Response Type:** Illuminate\Support\Str<br>
**Response Content:** Site Setting Value

<!-- div:right-panel -->

<!-- tabs:start -->

#### **Code**

```php
get_site_setting($key)
```

#### **Example**

```php
{{ get_site_setting('site_name') }}
```

#### **Inspect**

```php
function get_site_setting($key)
{
    $query = SiteSetting::where('key', $key)->first()->value ?? '';
    return $query;
}
```

<!-- tabs:end -->
<!-- panels:end -->

---

## Category

-   Example usage +

    ```php
    @foreach (get_categories_main() as $category)
            @if($category->sub_categories->count() > 0)
                <li class="nav-item @if($category->sub_categories->count() > 0) dropdown @endif">
                    <a class="nav-link dropdown-toggle" href="{{ route('category.detail', ['url' => $category->content->url ?? '']) }}">
                        {{ $category->content->name ?? '' }}
                    </a>
                    <ul class="dropdown-menu">
                        @foreach ($category->sub_categories as $sub_category)
                        <li><a class="dropdown-item" href="{{ route('category.detail', ['url' => $sub_category->content->url ?? '']) }}">{{ $sub_category->content->name ?? '' }}</a></li>
                        @endforeach
                    </ul>
                </li>
            @else
                <li class="nav-item">
                    <a class="nav-link" href="{{ route('category.detail', ['url' => $category->content->url ?? '']) }}">
                        {{ $category->content->name ?? '' }}
                    </a>
                </li>
            @endif
    @endforeach
    ```

<!-- panels:start -->
<!-- div:title-panel -->

### All Categories

<!-- div:left-panel -->

Get all categories with content.

> [!NOTE] > **Parameters**<br>
>
> -   **paginate**
>     -   **Type:** Integer
>     -   **Default:** 10
>     -   **Required:** false

?> **Response Type:** Illuminate\Support\Collection<br>
**Response Content:** App\Models\Category

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_categories_all($paginate = 10)
```

#### **Inspect**

```php
function get_categories_all($paginate = 10)
{
    $query = Categories::with('content')->whereHas('content')->orderBy('position', 'ASC')->paginate($paginate);
    return $query;
}
```

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Parent Categories

<!-- div:left-panel -->

Get only parent categories with content.

?> **Response Type:** Illuminate\Support\Collection<br>
**Response Content:** App\Models\Category

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_categories_main()
```

### **Example**

```php
@foreach (get_categories_main() as $category)
        @if($category->sub_categories->count() > 0)
            <li class="nav-item @if($category->sub_categories->count() > 0) dropdown @endif">
                <a class="nav-link dropdown-toggle" href="{{ route('category.detail', ['url' => $category->content->url ?? '']) }}">
                    {{ $category->content->name ?? '' }}
                </a>
                <ul class="dropdown-menu">
                    @foreach ($category->sub_categories as $sub_category)
                    <li><a class="dropdown-item" href="{{ route('category.detail', ['url' => $sub_category->content->url ?? '']) }}">{{ $sub_category->content->name ?? '' }}</a></li>
                    @endforeach
                </ul>
            </li>
        @else
            <li class="nav-item">
                <a class="nav-link" href="{{ route('category.detail', ['url' => $category->content->url ?? '']) }}">
                    {{ $category->content->name ?? '' }}
                </a>
            </li>
        @endif
@endforeach
```

#### **Inspect**

```php
function get_categories_main()
{
    $query = Categories::where('parent_id', '=', 0)->with('content')->whereHas('content')->orderBy('position', 'ASC')->get();
    return $query;
}
```

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Category Tree

<!-- div:left-panel -->

Get category tree with content.

> [!NOTE] > **Parameters**<br>
>
> -   **category_id**
>     -   **Type:** integer (\App\Models\Categories)
>     -   **Default:** -
>     -   **Required:** true

?> **Response Type:** Illuminate\Support\Collection<br>
**Response Content:** App\Models\Category

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_category_tree($category_id)
```

#### **Inspect**

```php
function get_category_tree($category_id)
{
    $top_categories = [];
    $sub_categories = [];

    $top_categories[] = Site::topCategoryList($category_id) ?? [];
    $sub_categories[] = Site::subCategoryList($category_id) ?? [];
    $merged = array_merge($top_categories, $sub_categories);

    return $merged;
}
```

<!-- tabs:end -->
<!-- panels:end -->

## Slider

<!-- panels:start -->
<!-- div:title-panel -->

### All Slider

<!-- div:left-panel -->

Get all categories with content.

?> **Response Type:** Illuminate\Support\Collection<br>
**Response Content:** App\Models\Slider

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
get_sliders()
```

#### **Example**

```php
@forelse (Site::get_sliders() as $item)
    <div>
        <h1 class="title">{{ $item->title }}</h1>
        @if($item->link)
             <a href="{{ $item->link ?? '#' }}" class="axil-btn btn-bg-white">
                <i class="fas fa-search"></i>
                {{ __('İncele') }}
            </a>
        @endif
    </div>
@empty
    {{ __('Slider bulunamadı.') }}
@endforelse
```

#### **Inspect**

```php
function get_sliders()
{
    $query = Slider::where('language_id', get_language_id())->with('language')->whereHas('language')->orderBy('position', 'DESC')->get();
    return $query;
}
```

<!-- tabs:end -->
<!-- panels:end -->

## Teams

<!-- panels:start -->
<!-- div:title-panel -->

### Get Team Members

<!-- div:left-panel -->

Get all team members.

?> **Response Type:** Illuminate\Support\Collection<br>
**Response Content:** App\Models\Team

<!-- div:right-panel -->

<!-- tabs:start -->

#### **Code**

```php
get_team_members()
get_team_member_media($member->id, $member->image)
```

#### **Example**

```php
@forelse(get_team_members() as $member)
    <div class="col-xl-4 col-md-6 col-lg-4">
            <div class="single_loyers text-center">
                    <div class="thumb">
                            <img src="{{ get_team_member_media($member->id, $member->image) }}" alt="">
                    </div>
                    <h3>{{ $member->name }}</h3>
                    <span>{{ $member->employee_position }}</span>
                    <div class="social_links">
                            <ul>
                                    @foreach($member->social_media_accounts as $account)
                                    <li><a href="{{ $account["url"] ?? '#' }}"> <i class="{{ $account["icon"] }}"></i> </a></li>
                                    @endforeach
                            </ul>
                    </div>
            </div>
    </div>
@endforeach
```

#### **Inspect**

```php
function get_team_members()
{
    $query = Team::all();
    return $query;
}
```

<!-- tabs:end -->
<!-- panels:end -->



## Log

<!-- panels:start -->
<!-- div:title-panel -->

### Search

<!-- div:left-panel -->

!> id is important for save log!

?> you must be include this script: <br>  <script src=\"{{ get_asset('softrede_folders/js/log.js') }}\"><\/script>

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Examle**

```php
 <form method="GET" action="{{ route('search.product') }}" id="search-form">
      <input type="search" class="form-control" name="q" id="search-input" placeholder="{{ __('Ara') }}">
 </form>
````

<!-- tabs:end -->
<!-- panels:end -->

<!-- panels:start -->
<!-- div:title-panel -->

### Get Search List

<!-- div:left-panel -->

Returns the user's last 8 searches.

<!-- div:right-panel -->
<!-- tabs:start -->

#### **Code**

```php
    const searchLocalStorage = localStorage.getItem('search') // ['search1','search2'...]
    if (searchLocalStorage) {
      const searchArray = JSON.parse(searchLocalStorage);
    }
```

#### **Examle**

```php
    <script>
        const oldSearch = $(".old-search");
        if (oldSearch) {
            const searchLocalStorage = localStorage.getItem('search');
            if (searchLocalStorage) {
                const searchArray = JSON.parse(searchLocalStorage);
                searchArray.forEach((search) => {
                    oldSearch.append(`
                    <div class="product-content">
                            <h6 class="product-title"><a href="{{ route('search.product') }}?q=${search}">${search}</a></h6>
                        </div>
                   `);
                });
            }
        }
    </script>
```

<!-- tabs:end -->
<!-- panels:end -->
