Skip to content

Commit

Permalink
first commit 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Sep 5, 2022
0 parents commit 5e0aaf5
Show file tree
Hide file tree
Showing 257 changed files with 14,360 additions and 0 deletions.
Empty file added CHANGELOG.md
Empty file.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright 2022 info@3x1.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
![Screenshot of VILT](https://raw.githubusercontent.com/3x1io/vilt-admin/main/art/stack.jpeg)

# VILT Framework

VILT stack admin panel

## Install

```bash
composer require queents/vilt
```
Now Install VILT

```bash
php artisan vilt:install
```

run NPM or YARN to install and build assets

```bash
npm i & npm run build
```

OR

```bash
yarn & yarn build
```

Generate Username and Password for Dashboard

```bash
php artisan roles:install
```

## Support

you can join our discord server to get support [VILT Admin](https://discord.gg/HUNYbgKDdx)

## Docs

look to the new docs of v4.00 on my website [Docs](https://vilt.3x1.io/docs/)

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Credits

- [3x1](https://github.com/3x1io)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "queents/vilt",
"description": "VILT stack HMVC dashboard and resource generator with ready to use modules",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Queents\\Vilt\\": "src/",
"Modules\\": "../../../Modules/"
}
},
"authors": [
{
"name": "Fady Mondy",
"email": "info@3x1.io"
}
],
"minimum-stability": "beta",
"require": {
"nwidart/laravel-modules": "^9.0",
"spatie/laravel-translatable": "^6.0",
"spatie/laravel-translation-loader": "^2.7",
"queents/base-module": "^1.0",
"queents/roles-module": "^1.0",
"queents/generator-module": "^1.0"
}
}
138 changes: 138 additions & 0 deletions src/Console/InstallVilt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

namespace Queents\Vilt\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class InstallVilt extends Command
{

public string $publish;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'vilt:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'This Command help you to generate the full file and view for VILT framework';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
$this->publish = base_path('vendor/queents/vilt/src/Publish');
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
/*
* Step 1 Copy And Publish Assets
*/
$this->info('Install Jetstream');
$this->runArtisan('jetstream:install', [
"stack"=>"inertia"
]);
$this->info('Migrate Jetstream Tables');
$this->runArtisan('migrate');
$this->info('Copy tailwind.config.js');
$this->handelFile('/tailwind.config.js', base_path('/tailwind.config.js'));
$this->info('Copy vite.config.js');
$this->handelFile('/vite.config.js', base_path('/vite.config.js'));
$this->info('Copy postcss.config.js');
$this->handelFile('/postcss.config.js', base_path('/postcss.config.js'));
$this->info('Copy package.json');
$this->handelFile('/package.json', base_path('/package.json'));
$this->info('Copy HandleInertiaRequests.php');
$this->handelFile('/app/Http/Middleware/HandleInertiaRequests.php', app_path('/Http/Middleware/HandleInertiaRequests.php'));
$this->info('Copy User.php');
$this->handelFile('/app/Models/User.php', app_path('/Models/User.php'));
$this->info('Copy RouteServiceProvider.php');
$this->handelFile('/app/Providers/RouteServiceProvider.php', app_path('/Providers/RouteServiceProvider.php'));
$this->info('Copy modules.php');
$this->handelFile('/config/modules.php', config_path('/modules.php'));
$this->info('Copy app.php');
$this->handelFile('/config/app.php', config_path('/app.php'));
$this->info('Copy placeholder.webp');
$this->handelFile('/public/placeholder.webp', public_path('/placeholder.webp'));
$this->info('Copy css');
$this->handelFile('/resources/css', resource_path('/css'), 'folder');
$this->info('Copy js');
$this->handelFile('/resources/js', resource_path('/js'), 'folder');
$this->info('Copy views');
$this->handelFile('/resources/views', resource_path('/views'), 'folder');
$this->info('Copy stubs');
$this->handelFile('/stubs/nwidart-stubs', base_path('/stubs/nwidart-stubs'), 'folder');
if(!$this->checkFile(base_path('Modules'))){
File::makeDirectory(base_path('Modules'));
}
$this->info('Copy modules_statuses.json');
$this->handelFile('/modules_statuses.json', base_path('/modules_statuses.json'));
$this->info('Clear cache');
$this->runArtisan('optimize:clear');
$this->info('Please run npm i & npm run build');
}

public function handelFile(string $from, string $to, string $type = 'file'): void
{
$checkIfFileEx = $this->checkFile($to);
if($checkIfFileEx){
$this->deleteFile($to);
$this->copyFile($this->publish .$from, $to, $type);
}
else {
$this->copyFile($this->publish .$from, $to, $type);
}
}

public function runArtisan(string $command, array $args=[]): string
{
Artisan::call($command, $args);
return Artisan::output();
}
public function checkFile(string $path): bool
{
return File::exists($path);
}

public function copyFile(string $from,string $to, string $type ='file'): bool
{
if($type === 'folder'){
$copy = File::copyDirectory($from , $to);
}
else {
$copy = File::copy($from , $to);
}

return $copy;
}
public function deleteFile(string $path, string $type ='file'): bool
{
if($type === 'folder'){
$delete = File::deleteDirectory($path);
}
else {
$delete = File::delete($path);
}

return $delete;
}
}
44 changes: 44 additions & 0 deletions src/Publish/app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Inertia\Middleware;
use Modules\Base\Services\Core\VILT;

class HandleInertiaRequests extends Middleware
{
/**
* The root template that's loaded on the first page visit.
*
* @see https://inertiajs.com/server-side-setup#root-template
* @var string
*/
protected $rootView = 'app';

/**
* Determines the current asset version.
*
* @see https://inertiajs.com/asset-versioning
* @param \Illuminate\Http\Request $request
* @return string|null
*/
public function version(Request $request): ?string
{
return parent::version($request);
}

/**
* Defines the props that are shared by default.
*
* @see https://inertiajs.com/shared-data
* @param \Illuminate\Http\Request $request
* @return array
*/
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'data' => VILT::get()
]);
}
}
63 changes: 63 additions & 0 deletions src/Publish/app/Models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
use HasApiTokens;
use HasFactory;
use HasProfilePhoto;
use Notifiable;
use TwoFactorAuthenticatable;
use HasRoles;

/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
'two_factor_recovery_codes',
'two_factor_secret',
];

/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];

/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = [
'profile_photo_url',
];
}
52 changes: 52 additions & 0 deletions src/Publish/app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/admin';

/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();

$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));

Route::middleware('web')
->group(base_path('routes/web.php'));
});
}

/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}
Loading

0 comments on commit 5e0aaf5

Please sign in to comment.