Laravel store() Method Won't Submit Data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm new to Laravel, so pardon me if this seems to be a foolish question.
I'm trying to create a form that creates a bank account, and I have two models named Team and AgentBank. My Team model has a one-to-many Eloquent relationship to AgentBank model.
The form below gets data from the Team model to supply the "team_id" input.
agent-bank/create.blade.php
<div class="col-3">
<div class="dark-panel card p-3">
<form method="post" action="{{ route('agent-bank.store') }}">
@csrf
<div class="form-group mb-2">
<select class="form-control" name="team_id">
<option value="" selected disabled>Select Team</option>
@foreach($teams as $team)
<option value={{ $team->id }}>{{ $team->team_name }}</option>
@endforeach
</select>
</div>
<div class="form-group mb-2">
<select class="form-control">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_name" type="text" placeholder="Account Name">
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_number" type="text" placeholder="Account Number">
</div>
<div class="form-group mb-2">
<select class="form-control" name="account_type">
<option value="" selected disabled>Select Function</option>
<option value="func1">FUNC1</option>
<option value="func2">FUNC2</option>
<option value="func3">FUNC3</option>
<option value="func4">FUNC4</option>
<option value="func5">FUNC5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_balance" type="text" placeholder="Account Balance">
</div>
<button type="submit" class="btn primary-button btn-sm mt-2">Submit</button>
</form>
</div>
</div>
Controller
public function store(Request $request)
{
$this->validate($request, [
'bank_name' => 'required',
'account_name' => 'required',
'account_number' => 'required|unique:agent_banks',
'account_type' => 'required'
]);
$data = $request->except('account_balance');
$data->account_balance = intval($request->account_balance);
$agentbank->fill($data)->save();
return redirect()->route('agent-bank.index')->with('flash_message', 'Bank ' . $agentbank->bank_name . ' ' . $agentbank->account_name . ' ' . $agentbank->account_number . ' succesfully added to ' . $teams->team_name);
}
Is there perhaps a typo or wrong code in this method that makes it so it can't be submitted?
Thank you.
php laravel laravel-blade
add a comment |
I'm new to Laravel, so pardon me if this seems to be a foolish question.
I'm trying to create a form that creates a bank account, and I have two models named Team and AgentBank. My Team model has a one-to-many Eloquent relationship to AgentBank model.
The form below gets data from the Team model to supply the "team_id" input.
agent-bank/create.blade.php
<div class="col-3">
<div class="dark-panel card p-3">
<form method="post" action="{{ route('agent-bank.store') }}">
@csrf
<div class="form-group mb-2">
<select class="form-control" name="team_id">
<option value="" selected disabled>Select Team</option>
@foreach($teams as $team)
<option value={{ $team->id }}>{{ $team->team_name }}</option>
@endforeach
</select>
</div>
<div class="form-group mb-2">
<select class="form-control">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_name" type="text" placeholder="Account Name">
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_number" type="text" placeholder="Account Number">
</div>
<div class="form-group mb-2">
<select class="form-control" name="account_type">
<option value="" selected disabled>Select Function</option>
<option value="func1">FUNC1</option>
<option value="func2">FUNC2</option>
<option value="func3">FUNC3</option>
<option value="func4">FUNC4</option>
<option value="func5">FUNC5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_balance" type="text" placeholder="Account Balance">
</div>
<button type="submit" class="btn primary-button btn-sm mt-2">Submit</button>
</form>
</div>
</div>
Controller
public function store(Request $request)
{
$this->validate($request, [
'bank_name' => 'required',
'account_name' => 'required',
'account_number' => 'required|unique:agent_banks',
'account_type' => 'required'
]);
$data = $request->except('account_balance');
$data->account_balance = intval($request->account_balance);
$agentbank->fill($data)->save();
return redirect()->route('agent-bank.index')->with('flash_message', 'Bank ' . $agentbank->bank_name . ' ' . $agentbank->account_name . ' ' . $agentbank->account_number . ' succesfully added to ' . $teams->team_name);
}
Is there perhaps a typo or wrong code in this method that makes it so it can't be submitted?
Thank you.
php laravel laravel-blade
add a comment |
I'm new to Laravel, so pardon me if this seems to be a foolish question.
I'm trying to create a form that creates a bank account, and I have two models named Team and AgentBank. My Team model has a one-to-many Eloquent relationship to AgentBank model.
The form below gets data from the Team model to supply the "team_id" input.
agent-bank/create.blade.php
<div class="col-3">
<div class="dark-panel card p-3">
<form method="post" action="{{ route('agent-bank.store') }}">
@csrf
<div class="form-group mb-2">
<select class="form-control" name="team_id">
<option value="" selected disabled>Select Team</option>
@foreach($teams as $team)
<option value={{ $team->id }}>{{ $team->team_name }}</option>
@endforeach
</select>
</div>
<div class="form-group mb-2">
<select class="form-control">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_name" type="text" placeholder="Account Name">
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_number" type="text" placeholder="Account Number">
</div>
<div class="form-group mb-2">
<select class="form-control" name="account_type">
<option value="" selected disabled>Select Function</option>
<option value="func1">FUNC1</option>
<option value="func2">FUNC2</option>
<option value="func3">FUNC3</option>
<option value="func4">FUNC4</option>
<option value="func5">FUNC5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_balance" type="text" placeholder="Account Balance">
</div>
<button type="submit" class="btn primary-button btn-sm mt-2">Submit</button>
</form>
</div>
</div>
Controller
public function store(Request $request)
{
$this->validate($request, [
'bank_name' => 'required',
'account_name' => 'required',
'account_number' => 'required|unique:agent_banks',
'account_type' => 'required'
]);
$data = $request->except('account_balance');
$data->account_balance = intval($request->account_balance);
$agentbank->fill($data)->save();
return redirect()->route('agent-bank.index')->with('flash_message', 'Bank ' . $agentbank->bank_name . ' ' . $agentbank->account_name . ' ' . $agentbank->account_number . ' succesfully added to ' . $teams->team_name);
}
Is there perhaps a typo or wrong code in this method that makes it so it can't be submitted?
Thank you.
php laravel laravel-blade
I'm new to Laravel, so pardon me if this seems to be a foolish question.
I'm trying to create a form that creates a bank account, and I have two models named Team and AgentBank. My Team model has a one-to-many Eloquent relationship to AgentBank model.
The form below gets data from the Team model to supply the "team_id" input.
agent-bank/create.blade.php
<div class="col-3">
<div class="dark-panel card p-3">
<form method="post" action="{{ route('agent-bank.store') }}">
@csrf
<div class="form-group mb-2">
<select class="form-control" name="team_id">
<option value="" selected disabled>Select Team</option>
@foreach($teams as $team)
<option value={{ $team->id }}>{{ $team->team_name }}</option>
@endforeach
</select>
</div>
<div class="form-group mb-2">
<select class="form-control">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_name" type="text" placeholder="Account Name">
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_number" type="text" placeholder="Account Number">
</div>
<div class="form-group mb-2">
<select class="form-control" name="account_type">
<option value="" selected disabled>Select Function</option>
<option value="func1">FUNC1</option>
<option value="func2">FUNC2</option>
<option value="func3">FUNC3</option>
<option value="func4">FUNC4</option>
<option value="func5">FUNC5</option>
</select>
</div>
<div class="form-group mb-2">
<input class="form-control" name="account_balance" type="text" placeholder="Account Balance">
</div>
<button type="submit" class="btn primary-button btn-sm mt-2">Submit</button>
</form>
</div>
</div>
Controller
public function store(Request $request)
{
$this->validate($request, [
'bank_name' => 'required',
'account_name' => 'required',
'account_number' => 'required|unique:agent_banks',
'account_type' => 'required'
]);
$data = $request->except('account_balance');
$data->account_balance = intval($request->account_balance);
$agentbank->fill($data)->save();
return redirect()->route('agent-bank.index')->with('flash_message', 'Bank ' . $agentbank->bank_name . ' ' . $agentbank->account_name . ' ' . $agentbank->account_number . ' succesfully added to ' . $teams->team_name);
}
Is there perhaps a typo or wrong code in this method that makes it so it can't be submitted?
Thank you.
php laravel laravel-blade
php laravel laravel-blade
edited Nov 26 '18 at 17:37
Karl Hill
3,46132446
3,46132446
asked Nov 23 '18 at 8:57
dycodingcodadycodingcoda
339
339
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I think It is problem of name
. Add name="bank_name"
in select attribute and try:
<div class="form-group mb-2">
<select class="form-control" name="bank_name">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
add a comment |
For the second problem samply change the input type of account_balance
to number.
<div class="form-group mb-2"> <input class="form-control" name="account_balance" type="number" placeholder="Account Balance"> </div>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443407%2flaravel-store-method-wont-submit-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think It is problem of name
. Add name="bank_name"
in select attribute and try:
<div class="form-group mb-2">
<select class="form-control" name="bank_name">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
add a comment |
I think It is problem of name
. Add name="bank_name"
in select attribute and try:
<div class="form-group mb-2">
<select class="form-control" name="bank_name">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
add a comment |
I think It is problem of name
. Add name="bank_name"
in select attribute and try:
<div class="form-group mb-2">
<select class="form-control" name="bank_name">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
I think It is problem of name
. Add name="bank_name"
in select attribute and try:
<div class="form-group mb-2">
<select class="form-control" name="bank_name">
<option value="" selected disabled>Select Bank</option>
<option value="bank1">BANK1</option>
<option value="bank2">BANK2</option>
<option value="bank3">BANK3</option>
<option value="bank4">BANK4</option>
<option value="bank5">BANK5</option>
</select>
</div>
edited Nov 23 '18 at 9:49
thisiskelvin
2,117414
2,117414
answered Nov 23 '18 at 9:02
Jigneshsinh RathodJigneshsinh Rathod
54539
54539
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
add a comment |
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
shame on me, i didn't saw that.. thank you, but now it got another error "Attempt to assign property 'account_balance' of non-object" and the problem line is "$data->account_balance = intval($request->input('account_balance'));", i'm trying to get the input value of "account_balance" and convert it to integer..as the table is set to accept integer value.. any insight? thank you :)
– dycodingcoda
Nov 23 '18 at 9:06
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
never mind, corrected the mistake..thank you for your help @jigneshsinh-rathod
– dycodingcoda
Nov 23 '18 at 9:14
add a comment |
For the second problem samply change the input type of account_balance
to number.
<div class="form-group mb-2"> <input class="form-control" name="account_balance" type="number" placeholder="Account Balance"> </div>
add a comment |
For the second problem samply change the input type of account_balance
to number.
<div class="form-group mb-2"> <input class="form-control" name="account_balance" type="number" placeholder="Account Balance"> </div>
add a comment |
For the second problem samply change the input type of account_balance
to number.
<div class="form-group mb-2"> <input class="form-control" name="account_balance" type="number" placeholder="Account Balance"> </div>
For the second problem samply change the input type of account_balance
to number.
<div class="form-group mb-2"> <input class="form-control" name="account_balance" type="number" placeholder="Account Balance"> </div>
answered Nov 26 '18 at 19:21
Taqi VaheedTaqi Vaheed
559
559
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443407%2flaravel-store-method-wont-submit-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown