Skip to content

Commit

Permalink
i dont know
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamadreza1388 committed Dec 7, 2024
2 parents 004ed2c + ed4a4d1 commit b6b1da4
Show file tree
Hide file tree
Showing 187 changed files with 47,555 additions and 3,042 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
64 changes: 64 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=auth
DB_USERNAME=root
DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
24 changes: 22 additions & 2 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
.idea
./.idea
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
/.zed
.idea
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SALAM AUTH

## Overview
SALAM AUTH is a robust authentication system designed to provide secure and efficient user authentication for web applications. It supports various authentication methods including password-based, OAuth, and multi-factor authentication.

## Features
- **Password-based Authentication**: Secure user login with hashed passwords.
- **OAuth Support**: Integration with popular OAuth providers like Google, Facebook, and GitHub.
- **Multi-factor Authentication**: Enhanced security with two-factor authentication.
- **User Management**: Admin interface for managing users and roles.
- **Session Management**: Secure session handling with token-based authentication.

## Installation
To install SALAM AUTH, follow these steps:

1. Clone the repository:
```sh
git clone https://github.com/SalamLang/Salam-Auth
cd salam-auth
```

2. Install dependencies:
```sh
npm install
```

3. Set up environment variables:
Create a `.env` file in the root directory and add the necessary

4. Run database migrations:
```sh
npm run migrate
```

5. Start the application:
```sh
npm start
```
80 changes: 80 additions & 0 deletions app/DataTables/Admin/UserDataTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace App\DataTables\Admin;

use App\Models\User;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Builder as HtmlBuilder;
use Yajra\DataTables\Html\Button;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;

class UserDataTable extends DataTable
{
public function dataTable(QueryBuilder $query): EloquentDataTable
{
$dataTable = new EloquentDataTable($query);

$dataTable?->addColumn('action', function ($model) {
$data = 'users';
$status = 'admin';

return view('components.action', compact('data', 'model', 'status'));
})?->addColumn('email_verified_at', function ($model) {
return view('components.email_verified', compact('model'));
})?->editColumn('updated_at', function ($query) {
return $query?->fa_updated_at();
})?->editColumn('role_id', function ($query) {
return __($query?->role()->first()->name);
})?->editColumn('created_at', function ($query) {
return $query?->fa_created_at();
});

// $column = request('filter_column');
// $value = request('filter_value');
// if ($column && $value) {
// $dataTable?->filter(function ($query) use ($column, $value) {
// $query?->where($column, 'like', '%'.$value.'%');
// });
// }
return $dataTable;
}

public function query(User $model): QueryBuilder
{
return $model->newQuery();
}

public function html(): HtmlBuilder
{
return $this->builder()
->setTableId('users-table')
->columns($this->getColumns())
->minifiedAjax()
->orderBy(0)
->selectStyleSingle()
->buttons([
Button::make('add')->text('ساخت جدید'),
]);
}

public function getColumns(): array
{
return [
Column::make('id')->title('ایدی'),
Column::make('name')->title('نام'),
Column::make('email')->title('ایمیل'),
Column::make('email_verified_at')->title('وضعیت تایید'),
Column::make('role_id')->title('نقش'),
Column::make('created_at')->title('ایجاد شده در'),
Column::make('updated_at')->title('اپدیت شده در'),
Column::make('action')->title('کاربردی'),
];
}

protected function filename(): string
{
return ',Users_'.date('YmdHis');
}
}
75 changes: 75 additions & 0 deletions app/DataTables/User/CodeDataTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace App\DataTables\User;

use App\Models\Code;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Builder as HtmlBuilder;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;

class CodeDataTable extends DataTable
{
public function dataTable(QueryBuilder $query): EloquentDataTable
{
$dataTable = new EloquentDataTable($query);

$dataTable
->addColumn('action', function ($model) {
$data = 'posts';

return view('components.action', compact('data', 'model'));
})
?->editColumn('created_at', function ($query) {
return $query?->fa_created_at();
})?->editColumn('code', function ($query) {
return mb_substr($query?->code, 0, 25).'.....';
})?->editColumn('title', function ($query) {
return mb_substr($query?->title, 0, 25).'.....';
});

// $column = request('filter_column');
// $value = request('filter_value');
// if ($column && $value) {
// $dataTable?->filter(function ($query) use ($column, $value) {
// $query?->where($column, 'like', '%'.$value.'%');
// });
// }

return $dataTable;
}

public function query(Code $model): QueryBuilder
{
return $model->newQuery()->where('user_id', auth()->user()->id);
}

public function html(): HtmlBuilder
{
return $this->builder()
->setTableId('codes-table')
->columns($this->getColumns())
->minifiedAjax()
->orderBy(0)
->selectStyleSingle()
->buttons([]);
}

public function getColumns(): array
{
return [
Column::make('id')->title('ایدی'),
Column::make('title')->title('عنوان'),
Column::make('user_id')->title('user'),
Column::make('code')->title('کد'),
Column::make('created_at')->title('ایجاد شده در'),
Column::make('action')->title('کاربردی'),
];
}

protected function filename(): string
{
return 'Codes_'.date('YmdHis');
}
}
60 changes: 60 additions & 0 deletions app/Http/Controllers/Admin/DashboardController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Code;
use App\Models\CodesVisit;
use App\Models\Email;
use App\Models\User;
use App\Models\Visit;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;

class DashboardController extends Controller
{
public function index()
{
function GetTables($day, $model)
{
$data = $model::where('created_at', '>=', Carbon::now()->subDays($day))
->selectRaw('DATE(created_at) as date, COUNT(*) as total')
->groupBy('date')
->orderBy('date', 'ASC')
->get();

$dates = $data->pluck('date')->toArray();
$totals = $data->pluck('total')->toArray();

return [
'dates' => $dates,
'totals' => $totals,
];
}

$users_history = GetTables(10, User::class);
$codes_history = GetTables(10, Code::class);
$codes_visits_history = GetTables(10, CodesVisit::class);
$emails_history = GetTables(10, Email::class);

$best_code_visit = DB::table('codes_visits')
->select('code_id', DB::raw('COUNT(*) as count'))
->groupBy('code_id')
->orderBy('count', 'DESC')
->limit(10)
->get();

$best_code_results = Code::whereIn('id', $best_code_visit->pluck('code_id')->toArray())->get();

$visits_history = GetTables(30, Visit::class);

return view('admin.dashboard', [
'users_history' => $users_history,
'codes_history' => $codes_history,
'codes_visits_history' => $codes_visits_history,
'emails_history' => $emails_history,
'best_code_results' => $best_code_results,
'visits_history' => $visits_history,
]);
}
}
Loading

0 comments on commit b6b1da4

Please sign in to comment.