Skip to content

Commit 31d58cf

Browse files
authored
Merge pull request #3 from MaestroError/integration-with-laravel-via-facade
Created Facade and registered in composer.json
2 parents 885ca2d + 0c2d9fc commit 31d58cf

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ Examples: `->exact("hello world", false, "1+")`
4646
- Remove need for "end" method in BuilderPattern ✔️
4747
- Add Dockblocs and comments for new methods ✔️
4848

49-
- Add facade for Laravel
50-
- Wrap Builder in class for static start
51-
- "string" and "source" for builder start✔️
52-
- "start" and "pattern" for builderPattern start✔️
49+
- Add facade for Laravel ✔️
50+
- Wrap Builder in class for static start ✔️
51+
- "string" and "source" for builder start ✔️
52+
- "start" and "pattern" for builderPattern start ✔️
5353
- Write documentation (add credit for https://regexr.com/ and ChatGPT)
5454
- Add automated tests on PR creation or on marging to main branch ✔️
5555

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,15 @@
2222
"allow-plugins": {
2323
"pestphp/pest-plugin": true
2424
}
25+
},
26+
"extra": {
27+
"laravel": {
28+
"providers": [
29+
"Maestroerror\\EloquentRegex\\EloquentRegexServiceProvider"
30+
],
31+
"aliases": {
32+
"EloquentRegex": "Maestroerror\\EloquentRegex\\Facades\\EloquentRegex"
33+
}
34+
}
2535
}
2636
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Maestroerror\EloquentRegex;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class EloquentRegexServiceProvider extends ServiceProvider
8+
{
9+
public function register()
10+
{
11+
$this->app->singleton('eloquentregex', function ($app) {
12+
return new \Maestroerror\EloquentRegex\EloquentRegex();
13+
});
14+
}
15+
16+
public function boot()
17+
{
18+
// booting code
19+
}
20+
}

src/Facades/EloquentRegex.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Maestroerror\EloquentRegex\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class EloquentRegex extends Facade
8+
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
14+
protected static function getFacadeAccessor()
15+
{
16+
return 'eloquentregex';
17+
}
18+
}

0 commit comments

Comments
 (0)