Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
First release
  • Loading branch information
vlados committed Aug 2, 2022
1 parent 52cd190 commit 8df57a6
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 67 deletions.
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
],
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.9.2",
"illuminate/contracts": "^9.0"
"illuminate/contracts": "^9.0",
"jaybizzle/crawler-detect": "^1.2",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand All @@ -43,7 +44,13 @@
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
"format": "vendor/bin/pint",
"post-autoload-dump": [
"@php artisan view:clear"
],
"post-update-cmd": [
"@php artisan view:clear"
]
},
"config": {
"sort-packages": true,
Expand Down
6 changes: 0 additions & 6 deletions config/blade-crawler-detect.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/migrations/create_blade_crawler_detect_table.php.stub

This file was deleted.

Empty file removed resources/views/.gitkeep
Empty file.
7 changes: 0 additions & 7 deletions src/LaravelBladeCrawlerDetect.php

This file was deleted.

29 changes: 18 additions & 11 deletions src/LaravelBladeCrawlerDetectServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@

namespace Vlados\LaravelBladeCrawlerDetect;

use Illuminate\Support\Facades\Blade;
use Jaybizzle\CrawlerDetect\CrawlerDetect;
use Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Vlados\LaravelBladeCrawlerDetect\Commands\LaravelBladeCrawlerDetectCommand;

class LaravelBladeCrawlerDetectServiceProvider extends PackageServiceProvider
{
public function packageRegistered()
{
$this->app->singleton('CrawlerDetect', function () {
return new \Jaybizzle\CrawlerDetect\CrawlerDetect();
});
}

public function packageBooted()
{
Blade::if('user', function () {
return !app(CrawlerDetect::class)->isCrawler();
});
}

public function configurePackage(Package $package): void
{
/*
* This class is a Package Service Provider
*
* More info: https://github.com/spatie/laravel-package-tools
*/
$package
->name('laravel-blade-crawler-detect')
->hasConfigFile()
->hasViews()
->hasMigration('create_laravel-blade-crawler-detect_table')
->hasCommand(LaravelBladeCrawlerDetectCommand::class);
->name('laravel-blade-crawler-detect');
}
}
8 changes: 6 additions & 2 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

it('can test', function () {
expect(true)->toBeTrue();
use Illuminate\Support\Facades\Blade;

it('if directive is compiled', function () {
$bladeSnippet = '@user test @enduser';
$expectedCode = '<?php if (\Illuminate\Support\Facades\Blade::check(\'user\')): ?> test <?php endif; ?>';
$this->assertEquals($expectedCode, Blade::compileString($bladeSnippet));
});

0 comments on commit 8df57a6

Please sign in to comment.