Skip to content

Commit 9dced3d

Browse files
authored
Update README.md
1 parent c7cef24 commit 9dced3d

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
66
## Installation
77

8-
## composer
8+
## Composer
99
composer require yudhees/laravel-vue-controller
1010
1111
## or
1212

1313
Begin by installing this package through Composer. Edit your project's `composer.json` file to require `yudhees/laravel-vue-controller`.
1414

1515
"require-dev": {
16-
"yudhees/laravel-vue-controller": "1.0"
16+
"yudhees/laravel-vue-controller": "1.5"
1717
}
1818

1919

@@ -22,9 +22,9 @@ Next, update Composer from the Terminal:
2222
composer update
2323

2424
> [!NOTE]
25-
> if You are using Laravel > 4 Skip the below step because The servie provider is auto discover then no neeed to register this provider
25+
> if You are using Laravel > 4 Skip the below step because The service provider is auto discover then no need to register this provider
2626
27-
## Laravel < 4
27+
## Laravel <=4
2828
Once this operation completes, the final step is to add the service provider. Open `config/app.php`, and add a new item to the providers array.
2929

3030
Yudhees\LaravelVueController\vuecontrollerserviceprovider::class
@@ -64,7 +64,7 @@ Once this operation completes, the final step is to add the service provider. Op
6464
# Global
6565
Two Ways to Inject controller function to vue Components
6666

67-
## Provie/Inject
67+
## Provide/Inject
6868
```js
6969
//resources/js/app.js
7070
createInertiaApp({
@@ -251,23 +251,26 @@ export default {
251251
## Vendor Files
252252
`vuecontroller.php file`
253253
```php
254-
<?php
255-
namespace Yudhees\LaravelVueController;
254+
namespace Yudhees\LaravelVueController;
256255

257256
use Illuminate\Http\Request;
258257
use Illuminate\Support\Facades\App;
259258
use Illuminate\Support\Facades\Response;
260259
class vuecontroller {
261-
public function __invoke(Request $request,$controller,$method){
262-
$controller = App::make("App\Http\Controllers\\{$controller}");
263-
if (!method_exists($controller, $method)) {
260+
public function __invoke(Request $request){
261+
$request->validate([
262+
'controller'=>'required',
263+
'function'=>'required',
264+
]);
265+
$function=$request->function;
266+
$controller = App::make("App\Http\Controllers\\{$request->controller}");
267+
if (!method_exists($controller, $function)) {
264268
return Response::json(['error' => 'Function does not exist'], 404);
265269
}
266-
$params=$request->all();
267-
return call_user_func_array([$controller, $method], $params);
270+
$params=$request->params;
271+
return call_user_func_array([$controller, $function], $params);
268272
}
269273
}
270-
271274
```
272275
## License
273276

0 commit comments

Comments
 (0)