-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set transformer and model, add traits
- Loading branch information
Showing
6 changed files
with
146 additions
and
18 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,20 @@ | ||
<?php | ||
|
||
namespace NavJobs\Transmit\Transmitters; | ||
|
||
use NavJobs\Transmit\Controller; | ||
|
||
trait Destroy | ||
{ | ||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
$this->model->findOrFail($id)->delete(); | ||
return $this->respondWithNoContent(); | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace NavJobs\Transmit\Transmitters; | ||
|
||
use NavJobs\Transmit\Controller; | ||
|
||
trait Index | ||
{ | ||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return $this->respondWithPaginatedCollection($this->model); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace NavJobs\Transmit\Transmitters; | ||
|
||
use NavJobs\Transmit\Controller; | ||
|
||
trait Show | ||
{ | ||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show($id) | ||
{ | ||
return $this->respondWithItem($this->model, function ($model) use ($id) { | ||
return $model->findOrFail($id); | ||
}); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace NavJobs\Transmit\Transmitters; | ||
|
||
use NavJobs\Transmit\Controller; | ||
|
||
trait Store | ||
{ | ||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store() | ||
{ | ||
$item = $this->model->create(request()->all()); | ||
return $this->respondWithItem($item); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace NavJobs\Transmit\Transmitters; | ||
|
||
use NavJobs\Transmit\Controller; | ||
use Illuminate\Http\Request; | ||
|
||
trait Update | ||
{ | ||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update($id, Request $request) | ||
{ | ||
return $this->respondWithItem($this->model, function ($model) use ($id, $request) { | ||
$item = $model->findOrFail($id); | ||
$item->fill($request->all()); | ||
$item->save(); | ||
return $item; | ||
}); | ||
} | ||
} |