Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/musonza/laravel-forms
Browse files Browse the repository at this point in the history
  • Loading branch information
musonza committed Jun 16, 2019
2 parents 600093b + fdc9daa commit 303abc4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
4 changes: 2 additions & 2 deletions config/laravel_forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
|
*/
'google_recaptcha_enabled' => true,
'google_recaptcha_key' => env(GOOGLE_RECAPTCHA_KEY),
'google_recaptcha_secret' => env(GOOGLE_RECAPTCHA_SECRET),
'google_recaptcha_key' => env('GOOGLE_RECAPTCHA_KEY'),
'google_recaptcha_secret' => env('GOOGLE_RECAPTCHA_SECRET'),
];
2 changes: 1 addition & 1 deletion src/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Session;
use Illuminate\Support\Facades\Session;

class Controller extends BaseController
{
Expand Down
6 changes: 5 additions & 1 deletion src/Http/Controllers/FieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

namespace Musonza\Form\Http\Controllers;

use Form;
use Musonza\Form\Transformers\FieldTypeTransformer;

class FieldController extends Controller
{
/**
* @var FieldTypeTransformer
*/
private $fieldTransformer;

public function __construct(FieldTypeTransformer $fieldTransformer)
{
$this->fieldTransformer = $fieldTransformer;
Expand Down
16 changes: 11 additions & 5 deletions src/Http/Controllers/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Musonza\Form\Http\Controllers;

use Form;
use Musonza\Form\Form;
use Musonza\Form\Http\Requests\CreateFormRequest;
use Musonza\Form\Http\Requests\DeleteFormRequest;
use Musonza\Form\Http\Requests\ListFormRequest;
Expand All @@ -13,15 +13,20 @@
class FormController extends Controller
{
private $formTransformer;
/**
* @var Form
*/
private $form;

/**
* FormController constructor.
*
* @param FormTransformer $formTransformer
*/
public function __construct(FormTransformer $formTransformer)
public function __construct(FormTransformer $formTransformer, Form $form)
{
$this->formTransformer = $formTransformer;
$this->form = $form;
}

/**
Expand Down Expand Up @@ -58,7 +63,7 @@ public function show(FormModel $form)
*/
public function store(CreateFormRequest $request)
{
$form = Form::create($request->validated());
$form = $this->form->create($request->validated());

return response($this->formTransformer->transformItem($form));
}
Expand All @@ -80,9 +85,10 @@ public function update(UpdateFormRequest $request, FormModel $form)
/**
* Deletes a form.
*
* @param DeleteFormRequest $request
* @param FormModel $form
* @param DeleteFormRequest $request
* @param FormModel $form
* @return \Illuminate\Http\Response
* @throws \Exception
*/
public function destroy(DeleteFormRequest $request, FormModel $form)
{
Expand Down
11 changes: 10 additions & 1 deletion src/Http/Controllers/FormFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Musonza\Form\Http\Controllers;

use Form;
use Illuminate\Http\Request;
use Musonza\Form\Http\Requests\CreateFormQuestionRequest;
use Musonza\Form\Http\Requests\UpdateFormQuestionRequest;
Expand All @@ -13,6 +12,16 @@

class FormFieldController extends Controller
{
/**
* @var FieldTypeTransformer
*/
private $fieldTypeTransformer;

/**
* @var FieldTransformer
*/
private $fieldTransformer;

public function __construct(FieldTransformer $fieldTransformer, FieldTypeTransformer $fieldTypeTransformer)
{
$this->fieldTransformer = $fieldTransformer;
Expand Down
25 changes: 21 additions & 4 deletions src/Http/Controllers/FormSubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Musonza\Form\Http\Controllers;

use Form;
use Illuminate\Http\Request;
use Musonza\Form\Form;
use Musonza\Form\Http\Requests\CreateFormSubmissionRequest;
use Musonza\Form\Models\Form as FormModel;
use Musonza\Form\Models\Submission;
Expand All @@ -12,12 +12,29 @@

class FormSubmissionController extends Controller
{
/**
* @var FormTransformer
*/
protected $formTransformer;

public function __construct(FormTransformer $formTransformer, SubmissionTransformer $submissionTransformer)
{
/**
* @var SubmissionTransformer
*/
private $submissionTransformer;

/**
* @var Form
*/
private $form;

public function __construct(
FormTransformer $formTransformer,
SubmissionTransformer $submissionTransformer,
Form $form
){
$this->formTransformer = $formTransformer;
$this->submissionTransformer = $submissionTransformer;
$this->form = $form;
}

public function index(FormModel $form)
Expand All @@ -38,7 +55,7 @@ public function create(Request $request, FormModel $form)
return response($form);
}

$googleRecaptchaEnabled = Form::googleRecaptchaEnabled();
$googleRecaptchaEnabled = $this->form->googleRecaptchaEnabled();

return view('laravel-forms::submissions.edit', compact('form', 'googleRecaptchaEnabled'));
}
Expand Down
1 change: 0 additions & 1 deletion src/Http/Controllers/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Musonza\Form\Http\Controllers;

use Illuminate\Http\Request;
use Musonza\Form\Models\Submission;

class SubmissionController extends Controller
Expand Down

0 comments on commit 303abc4

Please sign in to comment.