1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mtolhuys\LaravelSchematics\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory; |
6
|
|
|
use Mtolhuys\LaravelSchematics\Actions\Migration\CreateRelationMigrationAction; |
7
|
|
|
use Mtolhuys\LaravelSchematics\Actions\Relation\DeleteRelationAction; |
8
|
|
|
use Mtolhuys\LaravelSchematics\Actions\Relation\CreateRelationAction; |
9
|
|
|
use Mtolhuys\LaravelSchematics\Actions\Migration\DeleteMigrationAction; |
10
|
|
|
use Mtolhuys\LaravelSchematics\Http\Requests\CreateRelationRequest; |
11
|
|
|
use Mtolhuys\LaravelSchematics\Http\Requests\DeleteRelationRequest; |
12
|
|
|
use Symfony\Component\HttpFoundation\Response; |
13
|
|
|
use Illuminate\Support\Facades\Cache; |
14
|
|
|
use Illuminate\Routing\Controller; |
15
|
|
|
use ReflectionException; |
16
|
|
|
|
17
|
|
|
class RelationsController extends Controller |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param CreateRelationRequest $request |
21
|
|
|
* @return array |
22
|
|
|
* @throws ReflectionException |
23
|
|
|
*/ |
24
|
|
|
public function create(CreateRelationRequest $request) |
25
|
|
|
{ |
26
|
|
|
Cache::forget('schematics'); |
27
|
|
|
|
28
|
|
|
$result = (new CreateRelationAction())->execute($request); |
|
|
|
|
29
|
|
|
(new CreateRelationMigrationAction())->execute($request); |
30
|
|
|
|
31
|
|
|
$relation = $request->all(); |
32
|
|
|
$relation['method']['file'] = $result->file; |
33
|
|
|
$relation['method']['line'] = $result->line; |
34
|
|
|
|
35
|
|
|
return $relation; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param DeleteRelationRequest $request |
40
|
|
|
* @return ResponseFactory|\Illuminate\Http\Response|Response |
41
|
|
|
*/ |
42
|
|
|
public function delete(DeleteRelationRequest $request) |
43
|
|
|
{ |
44
|
|
|
Cache::forget('schematics'); |
45
|
|
|
|
46
|
|
|
(new DeleteRelationAction())->execute($request); |
47
|
|
|
(new DeleteMigrationAction())->execute($request); |
48
|
|
|
|
49
|
|
|
return response('Relation removed', 200); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: