File tree 5 files changed +77
-19
lines changed
app/Http/Controllers/Api/v1
5 files changed +77
-19
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ public function index(GenericListingRequest $request)
85
85
86
86
/**
87
87
* Store a new property
88
+ *
89
+ * `slug` field is set automatically using the `name` field when the status is set to <b>active</b> (value 1). Once set it can't be changed.
88
90
*/
89
91
public function store (StorePropertyRequest $ request )
90
92
{
Original file line number Diff line number Diff line change 22
22
<env name =" APP_MAINTENANCE_DRIVER" value =" file" />
23
23
<env name =" BCRYPT_ROUNDS" value =" 4" />
24
24
<env name =" CACHE_STORE" value =" array" />
25
- <env name =" DB_DATABASE" value =" testing" />
25
+ <env name =" DB_CONNECTION" value =" sqlite" />
26
+ <env name =" DB_DATABASE" value =" :memory:" />
26
27
<env name =" MAIL_MAILER" value =" array" />
27
28
<env name =" PULSE_ENABLED" value =" false" />
28
29
<env name =" QUEUE_CONNECTION" value =" sync" />
Original file line number Diff line number Diff line change 8
8
return $ request ->user ();
9
9
})->middleware ('auth:sanctum ' );
10
10
11
- Route::prefix ('v1 ' )->group (function () {
11
+ Route::prefix ('v1 ' )->name ( ' api.v1. ' )-> group (function () {
12
12
Route::apiResource ('properties ' , PropertyController::class);
13
- });
13
+ })-> name ( ' v1 ' ) ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
4
+ use App \Http \Controllers \Api \v1 \PropertyController ;
5
+ use Illuminate \Http \Response ;
6
+ use Illuminate \Testing \Fluent \AssertableJson ;
7
+ use App \Models \Property ;
8
+ use App \Models \User ;
9
+
10
+ uses (RefreshDatabase::class);
11
+
12
+ it ('index properties right json for no data ' , function (): void {
13
+ $ response = $ this ->getJson (
14
+ uri: route ('api.v1.properties.index ' ),
15
+ );
16
+
17
+ $ response
18
+ ->assertStatus (Response::HTTP_OK )
19
+ ->assertJson (
20
+ [
21
+ 'data ' => [],
22
+ 'links ' => [
23
+ 'first ' => route ('api.v1.properties.index ' ).'?page=1 ' ,
24
+ 'last ' => route ('api.v1.properties.index ' ).'?page=1 ' ,
25
+ 'prev ' => null ,
26
+ 'next ' => null
27
+ ],
28
+ 'meta ' => [
29
+ 'current_page ' => 1 ,
30
+ 'from ' => null ,
31
+ 'last_page ' => 1 ,
32
+ 'links ' => [
33
+ [
34
+ 'url ' => null ,
35
+ 'label ' => '« Previous ' ,
36
+ 'active ' => false
37
+ ],
38
+ [
39
+ 'url ' => route ('api.v1.properties.index ' ).'?page=1 ' ,
40
+ 'label ' => '1 ' ,
41
+ 'active ' => true
42
+ ],
43
+ [
44
+ 'url ' => null ,
45
+ 'label ' => 'Next » ' ,
46
+ 'active ' => false
47
+ ]
48
+ ],
49
+ 'path ' => route ('api.v1.properties.index ' ),
50
+ 'per_page ' => 15 ,
51
+ 'to ' => null ,
52
+ 'total ' => 0
53
+ ]
54
+ ]);
55
+ });
You can’t perform that action at this time.
0 commit comments