-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adicionando patter Repository na API Conceito
- Loading branch information
1 parent
008e077
commit f043390
Showing
5 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Interfaces; | ||
|
||
interface ConceitoRepositoryInterface | ||
{ | ||
public function getAllConceitos(); | ||
public function getConceitoById($conceitoId); | ||
public function deleteConceito($conceitoId); | ||
public function createConceito(array $conceitoDetails); | ||
public function updateConceito($conceitoId,array $newDetails); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use App\Interfaces\ConceitoRepositoryInterface; | ||
use App\Repositories\ConceitoRepository; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class RepositoryServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind(ConceitoRepositoryInterface::class,ConceitoRepository::class); | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Repositories; | ||
use App\Interfaces\ConceitoRepositoryInterface; | ||
use App\Models\Conceito; | ||
|
||
class ConceitoRepository implements ConceitoRepositoryInterface | ||
{ | ||
public function getAllConceitos() | ||
{ | ||
return Conceito::all(); | ||
} | ||
|
||
public function getConceitoById($conceitoId) | ||
{ | ||
return Conceito::findOrFail($conceitoId); | ||
} | ||
|
||
public function deleteConceito($conceitoId) | ||
{ | ||
Conceito::destroy($conceitoId); | ||
} | ||
|
||
public function createConceito(array $conceitoDetails) | ||
{ | ||
return Conceito::create($conceitoDetails); | ||
} | ||
|
||
public function updateConceito($conceitoId, array $newDetails) | ||
{ | ||
return Conceito::whereId($conceitoId)->update($newDetails); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters