Skip to content

Commit 5958086

Browse files
committed
first commit 🔥
0 parents  commit 5958086

40 files changed

+1843
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [3x1io]

CHANGELOG.md

Whitespace-only changes.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Fady Mondy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
![Screenshot](https://github.com/tomatophp/tomato-php/blob/master/art/screenshot.png)
2+
3+
# Tomato PHP
4+
5+
🍅 Tomato PHP is a Full CRUD Generator for [Splade](https://splade.dev/) & [Breeze Starter Kit](https://splade.dev/docs/breeze)
6+
7+
## Installation
8+
9+
```bash
10+
composer require tomatophp/tomato-php
11+
```
12+
13+
## Support
14+
15+
you can join our discord server to get support [TomatoPHP](https://discord.gg/Xqmt35Uh)
16+
17+
## Docs
18+
19+
you can check docs of this package on [Docs](https://docs.tomatophp.com/tomato-php)
20+
21+
## Changelog
22+
23+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
24+
25+
## Credits
26+
27+
- [Fady Mondy](https://github.com/3x1io)
28+
29+
## License
30+
31+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

SECURITY.md

Whitespace-only changes.

art/screenshot.png

31.9 KB
Loading

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "tomatophp/tomato-php",
3+
"type": "library",
4+
"description": "Full CRUD Generator for Splade & Breeze Starter Kit",
5+
"keywords": [
6+
"Splade",
7+
"Breeze",
8+
"inertiajs",
9+
"vuejs",
10+
"blade",
11+
"php8",
12+
"laravel"
13+
],
14+
"license": "MIT",
15+
"autoload": {
16+
"psr-4": {
17+
"TomatoPHP\\TomatoPHP\\": "src/"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"Tests\\": "tests/"
23+
}
24+
},
25+
"extra": {
26+
"laravel": {
27+
"providers": [
28+
"TomatoPHP\\TomatoPHP\\TomatoPHPServiceProvider"
29+
]
30+
}
31+
},
32+
"authors": [
33+
{
34+
"name": "Fady Mondy",
35+
"email": "[email protected]"
36+
}
37+
],
38+
"require": {
39+
"php": "^8.0.2",
40+
"tomatophp/tomato-splade": "^1.0",
41+
"tomatophp/tomato-breeze": "^1.0",
42+
"tomatophp/console-helpers": "^1.0",
43+
"blade-ui-kit/blade-heroicons": "^2.0",
44+
"maatwebsite/excel": "^3.1",
45+
"krlove/eloquent-model-generator": "^2.0",
46+
"spatie/laravel-medialibrary": "^10.7"
47+
}
48+
}

config/tomato-php.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
"stubs-path" => "vendors/tomatophp/tomato-php/stubs",
5+
];

src/Console/TomatoInstall.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace TomatoPHP\TomatoPHP\Console;
4+
5+
use Doctrine\DBAL\Schema\Schema;
6+
use Illuminate\Console\Command;
7+
use Nwidart\Modules\Facades\Module;
8+
use TomatoPHP\ConsoleHelpers\Traits\RunCommand;
9+
use TomatoPHP\TomatoPHP\Services\Generator\CRUDGenerator;
10+
11+
class TomatoInstall extends Command
12+
{
13+
14+
use RunCommand;
15+
/**
16+
* The name and signature of the console command.
17+
*
18+
* @var string
19+
*/
20+
protected $name = 'tomato:generate';
21+
22+
/**
23+
* The console command description.
24+
*
25+
* @var string
26+
*/
27+
protected $description = 'create a new CRUD for the application by tomato';
28+
29+
30+
/**
31+
* @return void
32+
*/
33+
public function handle(): void
34+
{
35+
//Get Table Name
36+
$check = true;
37+
while ($check){
38+
$tableName = $this->ask('🍅 Please input your table name you went to create CRUD? (ex: users)');
39+
40+
if(\Illuminate\Support\Facades\Schema::hasTable($tableName)){
41+
$check = false;
42+
}
43+
else {
44+
$this->error("Sorry table not found!");
45+
}
46+
}
47+
48+
//Check if user need to use HMVC
49+
$isModule=$this->ask('🍅 Do you went to use HMVC module? (y/n)', 'y');
50+
if(!$isModule){
51+
$isModule = 'y';
52+
}
53+
$moduleName= false;
54+
if($isModule === 'y'){
55+
$moduleName=$this->ask('🍅 Please input your module name? (ex: Translations)');
56+
if($moduleName){
57+
if(class_exists(\Nwidart\Modules\Facades\Module::class)){
58+
$check = \Nwidart\Modules\Facades\Module::find($moduleName);
59+
$this->info("🍅 Module not found but we will create it for you ");
60+
if(!$check){
61+
$this->artisanCommand(["module:make", $moduleName]);
62+
}
63+
}
64+
else {
65+
$this->error("🍅 Sorry nwidart/laravel-modules not installed please install it first");
66+
}
67+
}
68+
}
69+
70+
//Generate CRUD Service
71+
try {
72+
$resourceGenerator = new CRUDGenerator(tableName:$tableName,moduleName:$moduleName);
73+
$resourceGenerator->generate();
74+
$this->info('🍅 CRUD Has Been Generated Success');
75+
}catch (\Exception $e){
76+
$this->error($e->getMessage());
77+
return;
78+
}
79+
}
80+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace TomatoPHP\TomatoPHP\Http\Middleware;
4+
5+
use Closure;
6+
use Illuminate\Auth\Middleware\Authenticate as Middleware;
7+
use Illuminate\Http\Request;
8+
9+
class LanguageSwitcher extends Middleware
10+
{
11+
public function handle($request, Closure $next, ...$guards)
12+
{
13+
if(isset($_COOKIE['lang'])){
14+
$lang = json_decode($_COOKIE['lang']);
15+
app()->setLocale($lang->id);
16+
}
17+
else {
18+
$_COOKIE['lang'] = json_encode([
19+
'id' => config('app.locale'),
20+
'name' => config('app.locale') === 'en' ? 'English' : 'Arabic'
21+
]);
22+
}
23+
24+
return $next($request);
25+
}
26+
}

0 commit comments

Comments
 (0)