Skip to content

Commit e418940

Browse files
refactor: update stub files for improved response structure and routing configuration
1 parent 5db48ad commit e418940

File tree

9 files changed

+43
-41
lines changed

9 files changed

+43
-41
lines changed

src/Commands/stubs/composer.stub

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
"extra": {
1111
"laravel": {
1212
"providers": [],
13-
"aliases": {
14-
15-
}
13+
"aliases": {}
1614
}
1715
},
1816
"autoload": {

src/Commands/stubs/controller-api.stub

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,62 @@ class $CLASS$ extends Controller
1212
*/
1313
public function index()
1414
{
15-
//
16-
17-
return response()->json([]);
15+
return response()->json([
16+
'status' => 'success',
17+
'data' => [
18+
// 'users' => []
19+
],
20+
]);
1821
}
1922

2023
/**
2124
* Store a newly created resource in storage.
2225
*/
2326
public function store(Request $request)
2427
{
25-
//
26-
27-
return response()->json([]);
28+
return response()->json([
29+
'status' => 'success',
30+
'data' => [
31+
// 'user' => []
32+
],
33+
]);
2834
}
2935

3036
/**
3137
* Show the specified resource.
3238
*/
3339
public function show($id)
3440
{
35-
//
36-
37-
return response()->json([]);
41+
return response()->json([
42+
'status' => 'success',
43+
'data' => [
44+
// 'user' => []
45+
],
46+
]);
3847
}
3948

4049
/**
4150
* Update the specified resource in storage.
4251
*/
4352
public function update(Request $request, $id)
4453
{
45-
//
46-
47-
return response()->json([]);
54+
return response()->json([
55+
'status' => 'success',
56+
'data' => [
57+
// 'user' => []
58+
],
59+
]);
4860
}
4961

5062
/**
5163
* Remove the specified resource from storage.
5264
*/
5365
public function destroy($id)
5466
{
55-
//
56-
57-
return response()->json([]);
67+
return response()->json([
68+
'status' => 'success',
69+
'data' => null,
70+
'message' => 'Record deleted successfully.',
71+
]);
5872
}
5973
}

src/Commands/stubs/controller.invokable.stub

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ class $CLASS$ extends Controller
1010
/**
1111
* Handle the incoming request.
1212
*/
13-
public function __invoke(Request $request)
14-
{
15-
return response()->json([]);
16-
}
13+
public function __invoke(Request $request) {}
1714
}

src/Commands/stubs/controller.stub

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class $CLASS$ extends Controller
1818
/**
1919
* Show the form for creating a new resource.
2020
*/
21-
public function create()
22-
{
23-
return view('$LOWER_NAME$::create');
24-
}
21+
public function create() {}
2522

2623
/**
2724
* Store a newly created resource in storage.
@@ -31,18 +28,12 @@ class $CLASS$ extends Controller
3128
/**
3229
* Show the specified resource.
3330
*/
34-
public function show($id)
35-
{
36-
return view('$LOWER_NAME$::show');
37-
}
31+
public function show($id) {}
3832

3933
/**
4034
* Show the form for editing the specified resource.
4135
*/
42-
public function edit($id)
43-
{
44-
return view('$LOWER_NAME$::edit');
45-
}
36+
public function edit($id) {}
4637

4738
/**
4839
* Update the specified resource in storage.

src/Commands/stubs/factory.stub

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace $NAMESPACE$;
44

55
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use $MODEL_NAMESPACE$\$NAME$;
67

78
class $NAME$Factory extends Factory
89
{
910
/**
1011
* The name of the factory's corresponding model.
1112
*/
12-
protected $model = \$MODEL_NAMESPACE$\$NAME$::class;
13+
protected $model = $NAME$::class;
1314

1415
/**
1516
* Define the model's default state.

src/Commands/stubs/model.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class $CLASS$ extends Model
1515
*/
1616
protected $fillable = $FILLABLE$;
1717

18-
// protected static function newFactory(): $NAME$Factory
18+
// protected static function newFactory()
1919
// {
20-
// // return $NAME$Factory::new();
20+
// return $NAME$Factory::new();
2121
// }
2222
}

src/Commands/stubs/routes/api.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
use Illuminate\Support\Facades\Route;
44
use $MODULE_NAMESPACE$\$STUDLY_NAME$\$CONTROLLER_NAMESPACE$\$STUDLY_NAME$Controller;
55

6-
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
7-
Route::apiResource('$PLURAL_LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$');
6+
Route::middleware(['auth:api'])->prefix('v1')->group(function () {
7+
Route::apiResource('$PLURAL_LOWER_NAME$', $STUDLY_NAME$Controller::class);
88
});

src/Commands/stubs/routes/web.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ use Illuminate\Support\Facades\Route;
44
use $MODULE_NAMESPACE$\$STUDLY_NAME$\$CONTROLLER_NAMESPACE$\$STUDLY_NAME$Controller;
55

66
Route::middleware(['auth', 'verified'])->group(function () {
7-
Route::resource('$PLURAL_LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$');
7+
Route::resource('$PLURAL_LOWER_NAME$', $STUDLY_NAME$Controller::class);
88
});

src/Commands/stubs/scaffold/provider.stub

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class $CLASS$ extends ServiceProvider
129129

130130
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
131131

132-
Blade::componentNamespace(config('modules.namespace').'\\' . $this->name . '\\View\\Components', $this->nameLower);
132+
$namespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path')));
133+
Blade::componentNamespace($namespace, $this->nameLower);
133134
}
134135

135136
/**

0 commit comments

Comments
 (0)