Skip to content

Commit eafffc5

Browse files
committed
Clean up
1 parent 5b5705f commit eafffc5

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

src/Events/RestifyBeforeEach.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RestifyBeforeEach
1616

1717
/**
1818
* RestifyAfterEach constructor.
19-
* @param Request $request
19+
* @param $request
2020
*/
2121
public function __construct($request)
2222
{

src/Events/RestifyStarting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RestifyStarting
1616

1717
/**
1818
* RestifyServing constructor.
19-
* @param Request $request
19+
* @param $request
2020
*/
2121
public function __construct($request)
2222
{

src/Repositories/Crudable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function show(RestifyRequest $request)
4949
public function store(RestifyRequest $request)
5050
{
5151
$model = DB::transaction(function () use ($request) {
52-
[$model] = self::fillWhenStore(
52+
$model = self::fillWhenStore(
5353
$request, self::newModel()
5454
);
5555

@@ -72,7 +72,7 @@ public function store(RestifyRequest $request)
7272
public function update(RestifyRequest $request, $model)
7373
{
7474
DB::transaction(function () use ($request, $model) {
75-
[$model] = static::fillWhenUpdate($request, $model);
75+
$model = static::fillWhenUpdate($request, $model);
7676

7777
$model->save();
7878

@@ -97,4 +97,10 @@ public function destroy(RestifyRequest $request)
9797
return $this->response()
9898
->setStatusCode(RestResponse::REST_RESPONSE_DELETED_CODE);
9999
}
100+
101+
/**
102+
* @param null $request
103+
* @return mixed
104+
*/
105+
abstract public function response($request = null);
100106
}

src/Repositories/RepositoryFillFields.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ trait RepositoryFillFields
2121
*/
2222
public static function fillWhenStore(RestifyRequest $request, $model)
2323
{
24-
return [$model, static::fillFields(
24+
static::fillFields(
2525
$request, $model,
2626
(new static($model))->collectFields($request)
27-
), static::fillExtra($request, $model,
27+
);
28+
29+
static::fillExtra($request, $model,
2830
(new static($model))->collectFields($request)
29-
)];
31+
);
32+
33+
return $model;
3034
}
3135

3236
/**
@@ -36,12 +40,15 @@ public static function fillWhenStore(RestifyRequest $request, $model)
3640
*/
3741
public static function fillWhenUpdate(RestifyRequest $request, $model)
3842
{
39-
return [$model, static::fillFields(
43+
static::fillFields(
4044
$request, $model,
4145
(new static($model))->collectFields($request)
42-
), static::fillExtra($request, $model,
46+
);
47+
static::fillExtra($request, $model,
4348
(new static($model))->collectFields($request)
44-
)];
49+
);
50+
51+
return $model;
4552
}
4653

4754
/**

0 commit comments

Comments
 (0)