first commit

This commit is contained in:
tanch0
2024-06-10 18:06:58 +05:45
commit c569ea1d0c
1953 changed files with 85451 additions and 0 deletions

View File

@ -0,0 +1,50 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use App\Providers\ShortcodeProcessor;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register()
{
$this->app->singleton(ShortcodeProcessor::class, function ($app) {
return new ShortcodeProcessor();
});
}
/**
* Bootstrap any application services.
*/
public function boot()
{
Blade::directive('shortcode', function ($expression) {
list($shortcodeName, $shortcodeAttributes) = explode(',', $expression, 2);
return "<?php echo view('shortcodes.$shortcodeName', $shortcodeAttributes)->render(); ?>";
});
Blade::directive('processshortcodes', function ($expression) {
return "<?php echo app('App\Providers\ShortcodeProcessor')->process($expression); ?>";
});
Blade::directive('customshortcode', function ($expression) {
return "<?php echo app('App\Providers\ShortcodeProcessor')->processShortcodes($expression); ?>";
});
}
public function processShortcodes($content)
{
return preg_replace_callback('/\[([\w_]+)([^\]]*)\]/', function ($matches) {
$shortcodeName = $matches[1];
$shortcodeAttributes = str::of($matches[2])->trim()->replace("'", "\"")->__toString();
return "@shortcode('$shortcodeName', $shortcodeAttributes)";
}, $content);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
//
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
//
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*/
public function boot(): void
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}

View File

@ -0,0 +1,40 @@
<?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 your application's "home" route.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/dashboard';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*/
public function boot(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Str;
class ShortcodeProcessor
{
public function process($content)
{
return preg_replace_callback('/\[([\w_]+)([^\]]*)\]/', function ($matches) {
$shortcodeName = $matches[1];
$shortcodeAttributes = Str::of($matches[2])->trim()->replace("'", "\"")->__toString();
return "@shortcode('$shortcodeName', $shortcodeAttributes)";
}, $content);
}
public function processShortcodes($content)
{
return $this->process($content);
}
}