Refactor to deal with request and extract data to pass to service classes

This commit is contained in:
Jonny Barnes 2017-03-01 20:15:35 +00:00
parent 8ac32f5783
commit 4f57905bcc
5 changed files with 115 additions and 77 deletions

View file

@ -87,7 +87,19 @@ class NotesAdminController extends Controller
->withInput();
}
$note = $this->noteService->createNote($request);
$data = [];
$data['content'] = $request->input('content');
$data['in-reply-to'] = $request->input('in-reply-to');
$data['location'] = $request->input('location');
$data['syndicate'] = [];
if ($request->input('twitter')) {
$data['syndicate'][] = 'twitter';
}
if ($request->input('facebook')) {
$data['syndicate'][] = 'facebook';
}
$note = $this->noteService->createNote($data);
return view('admin.newnotesuccess', [
'id' => $note->id,

View file

@ -4,11 +4,19 @@ namespace App\Http\Controllers\Admin;
use App\Place;
use Illuminate\Http\Request;
use App\Services\PlaceService;
use App\Http\Controllers\Controller;
use Phaza\LaravelPostgis\Geometries\Point;
class PlacesAdminController extends Controller
{
protected $placeService;
public function __construct(PlaceService $placeService = null)
{
$this->placeService = $placeService ?? new PlaceService();
}
/**
* List the places that can be edited.
*
@ -61,7 +69,12 @@ class PlacesAdminController extends Controller
*/
public function store(Request $request)
{
$this->placeService->createPlace($request);
$data = [];
$data['name'] = $request->name;
$data['description'] = $request->description;
$data['latitude'] = $request->latitude;
$data['longitude'] = $request->longitude;
$place = $this->placeService->createPlace($data);
return view('admin.newplacesuccess');
}