andersao / andersao/l5-repository

Is it a BUG? The command:php artisan make:entity generates file error!

Aperta
#382 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PHP
Stelle
4.2k
Fork
880
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Version: "prettus/l5-repository": "^2.6"
```php
Would you like to create a Presenter? [y|N] (yes/no) [no]:
> N

Would you like to create a Validator? [y|N] (yes/no) [no]:
> N

Would you like to create a Controller? [y|N] (yes/no) [no]:
> y
```
Please notice that: Would you like to create a Validator? I choose the N, but the the generated files contains the Validator code.

For example:
```php
repository = $repository;
$this->validator = $validator;
}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria'));
$post1s = $this->repository->all();

if (request()->wantsJson()) {

return response()->json([
'data' => $post1s,
]);
}

return view('post1s.index', compact('post1s'));
}

/**
* Store a newly created resource in storage.
*
* @param Post1CreateRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(Post1CreateRequest $request)
{

try {

$this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE);

$post1 = $this->repository->create($request->all());

$response = [
'message' => 'Post1 created.',
'data' => $post1->toArray(),
];

if ($request->wantsJson()) {

return response()->json($response);
}

return redirect()->back()->with('message', $response['message']);
} catch (ValidatorException $e) {
if ($request->wantsJson()) {
return response()->json([
'error' => true,
'message' => $e->getMessageBag()
]);
}

return redirect()->back()->withErrors($e->getMessageBag())->withInput();
}
}

/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$post1 = $this->repository->find($id);

if (request()->wantsJson()) {

return response()->json([
'data' => $post1,
]);
}

return view('post1s.show', compact('post1'));
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{

$post1 = $this->repository->find($id);

return view('post1s.edit', compact('post1'));
}

/**
* Update the specified resource in storage.
*
* @param Post1UpdateRequest $request
* @param string $id
*
* @return Response
*/
public function update(Post1UpdateRequest $request, $id)
{

try {

$this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE);

$post1 = $this->repository->update($request->all(), $id);

$response = [
'message' => 'Post1 updated.',
'data' => $post1->toArray(),
];

if ($request->wantsJson()) {

return response()->json($response);
}

return redirect()->back()->with('message', $response['message']);
} catch (ValidatorException $e) {

if ($request->wantsJson()) {

return response()->json([
'error' => true,
'message' => $e->getMessageBag()
]);
}

return redirect()->back()->withErrors($e->getMessageBag())->withInput();
}
}

/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$deleted = $this->repository->delete($id);

if (request()->wantsJson()) {

return response()->json([
'message' => 'Post1 deleted.',
'deleted' => $deleted,
]);
}

return redirect()->back()->with('message', 'Post1 deleted.');
}
}

```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.