Cyber Monday! Get 25% off for as long as you keep your subscription. New subscribers only.

iroxbir

iroxbir

Member Since 1 Month Ago

Experience Points
510
Total
Experience

4,490 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
510 XP
Oct
26
1 month ago
Activity icon

Started a new Conversation How To Send Email Using Laravel?

I'm trying to send an email but i can't move anymore and that's my view:

<h1>Contact TODOParrot</h1>


<form action="contact" method="post">

<div class="form-group">
 <label>Your First Name</label>
 <input type="text" name="Fname" placeholder="Your First Name" />
</div>

<div class="form-group">
  <label>Your Last Name</label>
  <input type="text" name="Lname" placeholder="Your Last Name" />
</div>

<div class="form-group">
<label>Your Email</label>
  <input type="email" name="Email" placeholder="Your Email" />
</div>
<div class="form-group">
<label>Your Phone Number</label>
  <input type="text" name="Phone" placeholder="Your Phone" />
</div>
<div class="form-group">
<label>Your Order</label>
  <input type="text" name="Order" placeholder="Your Order" />
</div>

<div class="form-group">
    <button class="btn btn-default" name="Submit" type="Submit">Send Order</button>
</div>
</form>

and that is my controller :

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests\ContactFormRequest;


class aboutController extends Controller
{
    //
    public function create()
    {
        return view('about.contact');
    }

    public function store(ContactFormRequest $request)
    {
    	\Mail::send('about.contact',
        array(
            'Fname' => $request->get('Fname'),
            'Lname' => $request->get('Lname'),
            'Email' => $request->get('Email'),
            'Phone' => $request->get('Phone'),
            'Order' => $request->get('Order')
        ), function($message)
    {
        $message->from('[email protected]');
        $message->to('[email protected]', 'elbiheiry')->subject('TODOParrot Feedback');
    });

    	return \Redirect::route('contact')
      ->with('message', 'Thanks for contacting us!');
    }
}

And that's my route:

Route::get('contact', 
  ['as' => 'contact', 'uses' => '[email protected]']);
Route::post('contact', 
  ['as' => 'contact', 'uses' => '[email protected]']);

And that's the configuration in the .env file:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=ssl

And I removed the name and password in the question when I press send it gives me 'Forbidden' as a message. Can anyone help ?

Oct
22
1 month ago
Activity icon

Replied to How To Update Array With Foreach?

@snapey

I did not understand what you meant

Activity icon

Replied to How To Update Array With Foreach?

@automica

What am I doing now?

Activity icon

Replied to How To Update Array With Foreach?

@michaloravec

What are you saying? youuuuuuuuu

Activity icon

Replied to How To Update Array With Foreach?

@automica

What? What is Punxsutawney Phil?

I changed to all of @snapey's code

<script>
    $(document).ready(function() {
        let countStudy = 1;
        $('#addStudy').click(function () {
            countStudy++;
            dynamicStudy(countStudy);
        });
        //dynamicStudy(countStudy);
        function dynamicStudy(number) {
            let html = '' +
                '<div class="col-md-12 position-relative">\n' +
                '<i class="fas fa-times text-danger position-absolute"></i>' +
                '<div class="row">\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="grade_id">مقطع</label>\n' +
                '<select id="grade_id" name="study['+countStudy+']grade_id" class="form-control">\n' +
                '@foreach($grades as $grade)\n' +
                '<option value="{{ $grade->id }}">\n' +
                '{{ $grade->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="field">رشته تحصیلی</label>\n' +
                '<input id="field" name="study['+countStudy+']field" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="branch">گرایش/تخصص</label>\n' +
                '<input id="branch" name="study['+countStudy+']branch" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_id">نوع موسسه</label>\n' +
                '<select id="institution_id" name="study['+countStudy+']institution_id" class="form-control">\n' +
                '@foreach($institutions as $institution)\n' +
                '<option value="{{ $institution->id }}">{{ $institution->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_education">عنوان موسسه آموزشی</label>\n' +
                '<input id="institution_education" name="study['+countStudy+']institution_education" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="gpa">معدل</label>\n' +
                '<input id="gpa" name="study['+countStudy+']gpa" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="nation_id">کشور</label>\n' +
                '<select id="nation_id" name="study['+countStudy+']nation_id" class="form-control">\n' +
                '<option></option>\n' +
                '@foreach($countries as $country)\n' +
                '<option value="{{ $country->id }}">{{ $country->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="province_id">استان</label>\n' +
                '<select id="province_id" name="study['+countStudy+']province_id" class="form-control">\n' +
                '</select>\n' +
                '<input name="study['+countStudy+']province_name" id="province_id" class="form-control d-none">\n'+
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="town_id">شهر</label>\n' +
                '<select id="town_id" name="study['+countStudy+']town_id" class="form-control">\n' +
                '</select>\n' +
                '<input name="study['+countStudy+']town_name" id="town_id" class="form-control d-none">\n'+
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="entrance">ورود</label>\n' +
                '<input name="study['+countStudy+']entrance" id="entrance" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="graduate">فراغت از تحصیل</label>\n' +
                '<input name="study['+countStudy+']graduate" id="graduate" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
                '<input type="checkbox" class="custom-control-input" id="currently_studying" name="study['+countStudy+']currently_studying">\n' +
                '<label class="custom-control-label" for="currently_studying">در حال تحصیل</label>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>';
            $('#showStudy').append(html);
        }

        showDynamicStudy();
        function showDynamicStudy(){
            let html = '' +
                '@foreach(auth()->user()->educationals as $educational)\n'+
                '<div class="col-md-12 position-relative">\n' +
                '<i class="fas fa-times text-danger position-absolute"></i>' +
                '<div class="row">\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="grade_id">مقطع</label>\n' +
                '<select id="grade_id" name="study['+countStudy+']grade_id" class="form-control">\n' +
                '@foreach($grades as $grade)\n' +
                '<option value="{{ $grade->id }}" {{ $educational->grade_id == $grade->id ? 'selected' : '' }}>\n' +
                '{{ $grade->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="field">رشته تحصیلی</label>\n' +
                '<input id="field" name="study['+countStudy+']field" class="form-control" value="{{ $educational->field }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="branch">گرایش/تخصص</label>\n' +
                '<input id="branch" name="study['+countStudy+']branch" class="form-control" value="{{ $educational->branch }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_id">نوع موسسه</label>\n' +
                '<select id="institution_id" name="study['+countStudy+']institution_id" class="form-control">\n' +
                '@foreach($institutions as $institution)\n' +
                '<option value="{{ $institution->id }}" {{ $educational->institution_id == $institution->id ? 'selected' : '' }}>{{ $institution->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_education">عنوان موسسه آموزشی</label>\n' +
                '<input id="institution_education" name="study['+countStudy+']institution_education" class="form-control" value="{{ $educational->institution_education }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="gpa">معدل</label>\n' +
                '<input id="gpa" name="study['+countStudy+']gpa" class="form-control" value="{{ $educational->gpa }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="nation_id">کشور</label>\n' +
                '<select id="nation_id" name="study['+countStudy+']nation_id" class="form-control">\n' +
                '<option></option>\n' +
                '@foreach($countries as $country)\n' +
                '<option value="{{ $country->id }}" {{ $educational->nation_id == $country->id ? 'selected' : '' }}>\n' +
                '{{ $country->name }}\n'+
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="province_id">استان</label>\n' +
                '<select id="province_id" name="study['+countStudy+']province_id" class="form-control">\n' +
                '@foreach($states as $state)\n' +
                '<option value="{{ $state->id }}" {{ $educational->province_id == $state->id ? 'selected' : '' }}>\n' +
                '{{ $state->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '<input name="study['+countStudy+']province_name" id="province_id" class="form-control d-none" value="{{ $educational->province_name }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="town_id">شهر</label>\n' +
                '<select id="town_id" name="study['+countStudy+']town_id" class="form-control">\n' +
                '@foreach($cities as $city)\n' +
                '<option value="{{ $city->id }}" {{ $educational->town_id == $city->id ? 'selected' : '' }}>\n' +
                '{{ $city->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '<input name="study['+countStudy+']town_name" id="town_id" class="form-control d-none" value="{{ $educational->town_name }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="entrance">ورود</label>\n' +
                '<input name="study['+countStudy+']entrance" id="entrance" class="form-control" value="{{ $educational->entrance }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="graduate">فراغت از تحصیل</label>\n' +
                '<input name="study['+countStudy+']graduate" id="graduate" class="form-control" value="{{ $educational->graduate }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
                '<input type="checkbox" class="custom-control-input" id="currently_studying" name="study['+countStudy+']currently_studying" {{ $educational->currently_studying == 1 ? 'checked' : '' }}>\n' +
                '<label class="custom-control-label" for="currently_studying">در حال تحصیل</label>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '@endforeach';
            $('#showStudy').append(html);
        }
    });
</script>

But my problem did not solve yet.

Activity icon

Replied to How To Update Array With Foreach?

@snapey

I see this error again.

error

Activity icon

Replied to How To Update Array With Foreach?

I was crazy

<div class="container-fluid">
    <b>سوابق تحصیلی</b>
    <div class="mb-2 bg-white p-3 mb-5">
        <div class="row p-3" id="showStudy">

        </div>
        <div class="w-100 text-center">
            <p>سوابق تحصیلی دیگری را اضافه کنید.</p>
            <a id="addStudy" class="bg-primary text-white pt-2 pb-2 pl-3 pr-3 rounded-circle cursor-pointer">
                <i class="fas fa-plus"></i>
            </a>
        </div>
    </div>
</div>

<div class="wizard-buttons mb-5">
    <a class="btn btn-danger float-right" href="{{ route('pdf') }}">دریافت رزومه</a>
    <button type="button" class="btn btn-previous">قبلی</button>
    <button type="button" class="btn btn-next">بعدی</button>
</div>


<script>
    $(document).ready(function() {
        let countStudy = 1;
        $('#addStudy').click(function () {
            countStudy++;
            dynamicStudy(countStudy);
        });
        //dynamicStudy(countStudy);
        function dynamicStudy(number) {
            let html = '' +
                '<div class="col-md-12 position-relative">\n' +
                '<i class="fas fa-times text-danger position-absolute"></i>' +
                '<div class="row">\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="grade_id">مقطع</label>\n' +
                '<select id="grade_id" name="study[grade_id][]" class="form-control">\n' +
                '@foreach($grades as $grade)\n' +
                '<option value="{{ $grade->id }}">\n' +
                '{{ $grade->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="field">رشته تحصیلی</label>\n' +
                '<input id="field" name="study[field][]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="branch">گرایش/تخصص</label>\n' +
                '<input id="branch" name="study[branch][]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_id">نوع موسسه</label>\n' +
                '<select id="institution_id" name="study[institution_id][]" class="form-control">\n' +
                '@foreach($institutions as $institution)\n' +
                '<option value="{{ $institution->id }}">{{ $institution->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_education">عنوان موسسه آموزشی</label>\n' +
                '<input id="institution_education" name="study[institution_education][]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="gpa">معدل</label>\n' +
                '<input id="gpa" name="study[gpa][]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="nation_id">کشور</label>\n' +
                '<select id="nation_id" name="study[nation_id][]" class="form-control">\n' +
                '<option></option>\n' +
                '@foreach($countries as $country)\n' +
                '<option value="{{ $country->id }}">{{ $country->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="province_id">استان</label>\n' +
                '<select id="province_id" name="study[province_id][]" class="form-control">\n' +
                '</select>\n' +
                '<input name="study[province_name][]" id="province_id" class="form-control d-none">\n'+
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="town_id">شهر</label>\n' +
                '<select id="town_id" name="study[town_id][]" class="form-control">\n' +
                '</select>\n' +
                '<input name="study[town_name][]" id="town_id" class="form-control d-none">\n'+
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="entrance">ورود</label>\n' +
                '<input name="study[entrance][]" id="entrance" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="graduate">فراغت از تحصیل</label>\n' +
                '<input name="study[graduate][]" id="graduate" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
                '<input type="checkbox" class="custom-control-input" id="currently_studying" name="study[currently_studying][]">\n' +
                '<label class="custom-control-label" for="currently_studying">در حال تحصیل</label>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>';
            $('#showStudy').append(html);
        }

        showDynamicStudy();
        function showDynamicStudy(){
            let html = '' +
                '@foreach(auth()->user()->educationals as $educational)\n'+
                '<div class="col-md-12 position-relative">\n' +
                '<i class="fas fa-times text-danger position-absolute"></i>' +
                '<div class="row">\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="grade_id">مقطع</label>\n' +
                '<select id="grade_id" name="study[grade_id][]" class="form-control">\n' +
                '@foreach($grades as $grade)\n' +
                '<option value="{{ $grade->id }}" {{ $educational->grade_id == $grade->id ? 'selected' : '' }}>\n' +
                '{{ $grade->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="field">رشته تحصیلی</label>\n' +
                '<input id="field" name="study[field][]" class="form-control" value="{{ $educational->field }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="branch">گرایش/تخصص</label>\n' +
                '<input id="branch" name="study[branch][]" class="form-control" value="{{ $educational->branch }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_id">نوع موسسه</label>\n' +
                '<select id="institution_id" name="study[institution_id][]" class="form-control">\n' +
                '@foreach($institutions as $institution)\n' +
                '<option value="{{ $institution->id }}" {{ $educational->institution_id == $institution->id ? 'selected' : '' }}>{{ $institution->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_education">عنوان موسسه آموزشی</label>\n' +
                '<input id="institution_education" name="study[institution_education][]" class="form-control" value="{{ $educational->institution_education }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="gpa">معدل</label>\n' +
                '<input id="gpa" name="study[gpa][]" class="form-control" value="{{ $educational->gpa }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="nation_id">کشور</label>\n' +
                '<select id="nation_id" name="study[nation_id][]" class="form-control">\n' +
                '<option></option>\n' +
                '@foreach($countries as $country)\n' +
                '<option value="{{ $country->id }}" {{ $educational->nation_id == $country->id ? 'selected' : '' }}>\n' +
                '{{ $country->name }}\n'+
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="province_id">استان</label>\n' +
                '<select id="province_id" name="study[province_id][]" class="form-control">\n' +
                '@foreach($states as $state)\n' +
                '<option value="{{ $state->id }}" {{ $educational->province_id == $state->id ? 'selected' : '' }}>\n' +
                '{{ $state->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '<input name="study[province_name][]" id="province_id" class="form-control d-none" value="{{ $educational->province_name }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="town_id">شهر</label>\n' +
                '<select id="town_id" name="study[town_id][]" class="form-control">\n' +
                '@foreach($cities as $city)\n' +
                '<option value="{{ $city->id }}" {{ $educational->town_id == $city->id ? 'selected' : '' }}>\n' +
                '{{ $city->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '<input name="study[town_name][]" id="town_id" class="form-control d-none" value="{{ $educational->town_name }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="entrance">ورود</label>\n' +
                '<input name="study[entrance][]" id="entrance" class="form-control" value="{{ $educational->entrance }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="graduate">فراغت از تحصیل</label>\n' +
                '<input name="study[graduate][]" id="graduate" class="form-control" value="{{ $educational->graduate }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
                '<input type="checkbox" class="custom-control-input" id="currently_studying" name="study[currently_studying][]" {{ $educational->currently_studying == 1 ? 'checked' : '' }}>\n' +
                '<label class="custom-control-label" for="currently_studying">در حال تحصیل</label>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '@endforeach';
            $('#showStudy').append(html);
        }
    });
</script>
Activity icon

Replied to How To Update Array With Foreach?

@automica

I see this error again.

error

Activity icon

Replied to How To Update Array With Foreach?

I send you a photo to believe.

error

Activity icon

Replied to How To Update Array With Foreach?

@automica

People will stop helping you if they feel you aren't listening or paying attention.

I did not see your code,

I change in my blade

<input  name="study[field][]">
<input  name="study[branch][]">
<input  name="study[grade_id][]">
<input  name="study[institution_id][]">
<input  name="study[institution_education][]">
<input  name="study[gpa][]">
<input  name="study[nation_id][]">
<input  name="study[province_id][]">
<input  name="study[town_id][]">
<input  name="study[branch][]">
<input  name="study[province_name][]">
<input  name="study[town_name][]">
<input  name="study[entrance][]">
<input  name="study[graduate][]">
<input  name="study[currently_studying][]">

I see this error

ثققخق

Activity icon

Replied to How To Update Array With Foreach?

@automica

I did not see, sorry

Activity icon

Replied to How To Update Array With Foreach?

@automica

<input  name="study[grade_id]">
Activity icon

Replied to How To Update Array With Foreach?

@automica

YES, YES,

I see this dd i.stack.imgur.com/z9yqB.png

Activity icon

Replied to How To Update Array With Foreach?

@automica OK,

if you have multiples you need to change the name to be an array

How to do it?

Oct
21
1 month ago
Activity icon

Replied to How To Update Array With Foreach?

Is there anyone to answer our question?

Activity icon

Replied to How To Update Array With Foreach?

And when run this code

dd($request->study);

I see this demo.

array:14 [▼
  "grade_id" => "2"
  "field" => "compter"
  "branch" => "compter"
  "institution_id" => "3"
  "institution_education" => "adobe"
  "gpa" => "20"
  "nation_id" => "1"
  "province_id" => "4"
  "province_name" => null
  "town_id" => "45"
  "town_name" => null
  "entrance" => "1376"
  "graduate" => "1390"
  "currently_studying" => "on"
]


Activity icon

Replied to How To Update Array With Foreach?

dd($value); => "2"

And

dd($key); => "grade_id"

Activity icon

Replied to How To Update Array With Foreach?

@snapey

When I after on + click, After I filled it text boxes, And After I click on submit button, it display 2

two

Activity icon

Replied to How To Update Array With Foreach?

I swear to God that I do not intend to interfere in this free forum.

I just have a difficult project for first time that I can not solve.

And I think in the next project I do not need to ask the forum.

I am a job of programming Laravel. I love Laravel.

I tried in watches but I did not solve my problem.

Activity icon

Replied to How To Update Array With Foreach?

@snapey

I have value(s) in the grade_id in select.

Do you have any ability to debug your code?

No.

Activity icon

Replied to How To Update Array With Foreach?

@automica

I changed this

    foreach ($request->study as $key => $value) {
        Educational::firstOrCreate(['user_id' => auth()->id()], [
            'grade_id' => $request->grade_id[$key],
            'field' => $request->field[$key],
            'institution_id' => $request->institution_id[$key],
            'branch' => $request->branch[$key],
            'institution_education' => $request->institution_education[$key],
            'gpa' => $request->gpa[$key],
            'nation_id' => $request->nation_id[$key],
            'province_id' => $request->province_id[$key],
            'town_id' => $request->town_id[$key],
            'province_name' => $request->province_name[$key],
            'town_name' => $request->town_name[$key],
            'entrance' => $request->entrance[$key],
            'graduate' => $request->graduate[$key],
            'currently_studying' => $request->has("currently_studying.$key"),
        ]);
    }

but I get this error

error

Activity icon

Started a new Conversation How To Update Array With Foreach?

I used all five methods but none of them worked. And not stored in the database.

I have a row in educationals table

table

And my form is like this demo

form

My blade

<input  name="study[field]">
<input  name="study[branch]">
<input  name="study[grade_id]">
<input  name="study[institution_id]">
<input  name="study[institution_education]">
<input  name="study[gpa]">
<input  name="study[nation_id]">
<input  name="study[province_id]">
<input  name="study[town_id]">
<input  name="study[branch]">
<input  name="study[province_name]">
<input  name="study[town_name]">
<input  name="study[entrance]">
<input  name="study[graduate]">
<input  name="study[currently_studying]">

my controller

    foreach ($request->field as $key => $value) {
        Educational::firstOrCreate(['user_id' => auth()->id()], [
            'grade_id' => $request->grade_id[$key],
            'field' => $request->field[$key],
            'institution_id' => $request->institution_id[$key],
            'branch' => $request->branch[$key],
            'institution_education' => $request->institution_education[$key],
            'gpa' => $request->gpa[$key],
            'nation_id' => $request->nation_id[$key],
            'province_id' => $request->province_id[$key],
            'town_id' => $request->town_id[$key],
            'province_name' => $request->province_name[$key],
            'town_name' => $request->town_name[$key],
            'entrance' => $request->entrance[$key],
            'graduate' => $request->graduate[$key],
            'currently_studying' => $request->has("currently_studying.$key"),
        ]);
    }

I get this error.

dd

After get dd:

dd

Activity icon

Started a new Conversation Invalid Argument Supplied For Foreach()

I have a row in educationals table

table

And my form is like this demo

form

My blade

<input  name="study[field]">
<input  name="study[branch]">
<input  name="study[grade_id]">
<input  name="study[institution_id]">
<input  name="study[institution_education]">
<input  name="study[gpa]">
<input  name="study[nation_id]">
<input  name="study[province_id]">
<input  name="study[town_id]">
<input  name="study[branch]">
<input  name="study[province_name]">
<input  name="study[town_name]">
<input  name="study[entrance]">
<input  name="study[graduate]">
<input  name="study[currently_studying]">

my controller

    foreach ($request->field as $key => $value) {
        Educational::firstOrCreate(['user_id' => auth()->id()], [
            'grade_id' => $request->grade_id[$key],
            'field' => $request->field[$key],
            'institution_id' => $request->institution_id[$key],
            'branch' => $request->branch[$key],
            'institution_education' => $request->institution_education[$key],
            'gpa' => $request->gpa[$key],
            'nation_id' => $request->nation_id[$key],
            'province_id' => $request->province_id[$key],
            'town_id' => $request->town_id[$key],
            'province_name' => $request->province_name[$key],
            'town_name' => $request->town_name[$key],
            'entrance' => $request->entrance[$key],
            'graduate' => $request->graduate[$key],
            'currently_studying' => $request->has("currently_studying.$key"),
        ]);
    }

I get this error.

dd

Activity icon

Replied to FirstOrCreate And FirstOrNew Not Worling In Laravel

These are my last questions. Answer this so that next time I do not need to ask the association.

Oct
20
1 month ago
Activity icon

Replied to FirstOrCreate And FirstOrNew Not Worling In Laravel

@ilijatatalovic

I added protected $guarded = []; in Educational model, Bu it did not save in database.

Activity icon

Replied to FirstOrCreate And FirstOrNew Not Worling In Laravel

My questions are hidden Yahweh

Activity icon

Started a new Conversation FirstOrCreate And FirstOrNew Not Worling In Laravel

I have a row in educationals table

table

And my form is like this demo

form

When I click Add other academic record, it add new row, and when I'm filling new data And in the last step, when I click on the submit, nothing happens in the database.

The first method:

foreach ($request->field as $key => $value) {
    $educational = Educational::firstOrNew(['user_id' => auth()->id()]);
    $educational->user_id = auth()->id();
    $educational->grade_id = $request->grade_id[$key];
    $educational->field = $request->field[$key];
    $educational->institution_id = $request->institution_id[$key];
    $educational->branch = $request->branch[$key];
    $educational->institution_education = $request->institution_education[$key];
    $educational->gpa = $request->gpa[$key];
    $educational->nation_id = $request->nation_id[$key];
    $educational->province_id = $request->province_id[$key];
    $educational->town_id = $request->town_id[$key];
    $educational->province_name = $request->province_name[$key];
    $educational->town_name = $request->town_name[$key];
    $educational->entrance = $request->entrance[$key];
    $educational->graduate = $request->graduate[$key];
    $educational->currently_studying = $request->has("currently_studying.$key");
    $educational->save();
}

The second method:

foreach ($request->field as $key => $value) {
    try {
        $educational = new Educational;
        $educational->user_id = auth()->id();
        $educational->grade_id = $request->grade_id[$key];
        $educational->field = $request->field[$key];
        $educational->institution_id = $request->institution_id[$key];
        $educational->branch = $request->branch[$key];
        $educational->institution_education = $request->institution_education[$key];
        $educational->gpa = $request->gpa[$key];
        $educational->nation_id = $request->nation_id[$key];
        $educational->province_id = $request->province_id[$key];
        $educational->town_id = $request->town_id[$key];
        $educational->province_name = $request->province_name[$key];
        $educational->town_name = $request->town_name[$key];
        $educational->entrance = $request->entrance[$key];
        $educational->graduate = $request->graduate[$key];
        $educational->currently_studying = $request->has("currently_studying.$key");
        $educational->save();
    } catch (Exception $e) {
        dd($e->getMessage());
    }
}

The third method

foreach ($request->field as $key => $value) {
    Educational::firstOrCreate([
        'user_id' => auth()->id(),
        'grade_id' => $request->grade_id[$key],
        'field' => $request->field[$key],
        'institution_id' => $request->institution_id[$key],
        'branch' => $request->branch[$key],
        'institution_education' => $request->institution_education[$key],
        'gpa' => $request->gpa[$key],
        'nation_id' => $request->nation_id[$key],
        'province_id' => $request->province_id[$key],
        'town_id' => $request->town_id[$key],
        'province_name' => $request->province_name[$key],
        'town_name' => $request->town_name[$key],
        'entrance' => $request->entrance[$key],
        'graduate' => $request->graduate[$key],
        'currently_studying' => $request->has("currently_studying.$key"),
    ]);
}

The fourth method

foreach ($request->field as $key => $value) {
    try {
    $educational = Educational::firstOrCreate(['user_id' => auth()->id()]);
        $educational->user_id = auth()->id();
        $educational->grade_id = $request->grade_id[$key];
        $educational->field = $request->field[$key];
        $educational->institution_id = $request->institution_id[$key];
        $educational->branch = $request->branch[$key];
        $educational->institution_education = $request->institution_education[$key];
        $educational->gpa = $request->gpa[$key];
        $educational->nation_id = $request->nation_id[$key];
        $educational->province_id = $request->province_id[$key];
        $educational->town_id = $request->town_id[$key];
        $educational->province_name = $request->province_name[$key];
        $educational->town_name = $request->town_name[$key];
        $educational->entrance = $request->entrance[$key];
        $educational->graduate = $request->graduate[$key];
        $educational->currently_studying = $request->has("currently_studying.$key");
        $educational->save();
    } catch (Exception $e) {
        dd($e->getMessage());
    }
}

The fifth method

public function update(Request $request) {
    $user = auth()->user();
    $user->image = $path;
    $user->first_name = $request->first_name;
    $user->last_name = $request->last_name;
    $user->job_title = $request->job_title;
    $user->gender = $request->gender;
    $user->marital = $request->marital;
    $user->soldier_id = $request->soldier_id;
    $user->birth_date_day = $request->birth_date_day;
    $user->month_id = $request->month_id;
    $user->birth_date_year = $request->birth_date_year;
    $user->email = $request->email;
    $user->mobile = $request->mobile;
    $user->telephone = $request->telephone;
    $user->website = $request->website;
    $user->save();
    foreach ($request->field as $key => $value) {
        if ($user->where('user_id', auth()->id())) {
            $educational = $user->findOrFail('user_id');
        } else {
            $educational = new Educational;
        }
        $educational->user_id = auth()->id();
        $educational->grade_id = $request->grade_id[$key];
        $educational->field = $request->field[$key];
        $educational->institution_id = $request->institution_id[$key];
        $educational->branch = $request->branch[$key];
        $educational->institution_education = $request->institution_education[$key];
        $educational->gpa = $request->gpa[$key];
        $educational->land_id = $request->land_id[$key];
        $educational->province_id = $request->province_id[$key];
        $educational->town_id = $request->town_id[$key];
        $educational->province_name = $request->province_name[$key];
        $educational->town_name = $request->town_name[$key];
        $educational->entrance = $request->entrance[$key];
        $educational->graduate = $request->graduate[$key];
        $educational->currently_studying = $request->has("currently_studying.$key");
        $educational->save();
    }
}

My blade

<div class="container-fluid">
    <b>سوابق تحصیلی</b>
    <div class="mb-2 bg-white p-3 mb-5">
        <div class="row p-3" id="showStudy">

        </div>
        <div class="w-100 text-center">
            <p>سوابق تحصیلی دیگری را اضافه کنید.</p>
            <a id="addStudy" class="bg-primary text-white pt-2 pb-2 pl-3 pr-3 rounded-circle cursor-pointer">
                <i class="fas fa-plus"></i>
            </a>
        </div>
    </div>
</div>

<script>    
    $(document).ready(function() {
        let countStudy = 1;
        $('#addStudy').click(function () {
            countStudy++;
            dynamicStudy(countStudy);
        });
        //dynamicStudy(countStudy);
        function dynamicStudy(number) {
            let html = '' +
                '<div class="col-md-12 position-relative">\n' +
                '<i class="fas fa-times text-danger position-absolute"></i>' +
                '<div class="row">\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="grade_id">مقطع</label>\n' +
                '<select id="grade_id" name="grade_id[]" class="form-control">\n' +
                '@foreach($grades as $grade)\n' +
                '<option value="{{ $grade->id }}">\n' +
                '{{ $grade->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="field">رشته تحصیلی</label>\n' +
                '<input id="field" name="field[]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="branch">گرایش/تخصص</label>\n' +
                '<input id="branch" name="branch[]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_id">نوع موسسه</label>\n' +
                '<select id="institution_id" name="institution_id[]" class="form-control">\n' +
                '@foreach($institutions as $institution)\n' +
                '<option value="{{ $institution->id }}">{{ $institution->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_education">عنوان موسسه آموزشی</label>\n' +
                '<input id="institution_education" name="institution_education[]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="gpa">معدل</label>\n' +
                '<input id="gpa" name="gpa[]" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="nation_id">کشور</label>\n' +
                '<select id="nation_id" name="nation_id[]" class="form-control">\n' +
                '<option></option>\n' +
                '@foreach($countries as $country)\n' +
                '<option value="{{ $country->id }}">{{ $country->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="province_id">استان</label>\n' +
                '<select id="province_id" name="province_id[]" class="form-control">\n' +
                '</select>\n' +
                '<input name="province_name[]" id="province_id" class="form-control d-none">\n'+
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="town_id">شهر</label>\n' +
                '<select id="town_id" name="town_id[]" class="form-control">\n' +
                '</select>\n' +
                '<input name="town_name[]" id="town_id" class="form-control d-none">\n'+
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="entrance">ورود</label>\n' +
                '<input name="entrance[]" id="entrance" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="graduate">فراغت از تحصیل</label>\n' +
                '<input name="graduate[]" id="graduate" class="form-control">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
                '<input type="checkbox" class="custom-control-input" id="currently_studying" name="currently_studying[]">\n' +
                '<label class="custom-control-label" for="currently_studying">در حال تحصیل</label>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>';
            $('#showStudy').append(html);
        }

        showDynamicStudy();
        function showDynamicStudy(){
            let html = '' +
                '@foreach(auth()->user()->educationals as $educational)\n'+
                '<div class="col-md-12 position-relative">\n' +
                '<i class="fas fa-times text-danger position-absolute"></i>' +
                '<div class="row">\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="grade_id">مقطع</label>\n' +
                '<select id="grade_id" name="grade_id[]" class="form-control">\n' +
                '@foreach($grades as $grade)\n' +
                '<option value="{{ $grade->id }}" {{ $educational->grade_id == $grade->id ? 'selected' : '' }}>\n' +
                '{{ $grade->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="field">رشته تحصیلی</label>\n' +
                '<input id="field" name="field[]" class="form-control" value="{{ $educational->field }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="branch">گرایش/تخصص</label>\n' +
                '<input id="branch" name="branch[]" class="form-control" value="{{ $educational->branch }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_id">نوع موسسه</label>\n' +
                '<select id="institution_id" name="institution_id[]" class="form-control">\n' +
                '@foreach($institutions as $institution)\n' +
                '<option value="{{ $institution->id }}" {{ $educational->institution_id == $institution->id ? 'selected' : '' }}>{{ $institution->name }}</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="institution_education">عنوان موسسه آموزشی</label>\n' +
                '<input id="institution_education" name="institution_education[]" class="form-control" value="{{ $educational->institution_education }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="gpa">معدل</label>\n' +
                '<input id="gpa" name="gpa[]" class="form-control" value="{{ $educational->gpa }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="nation_id">کشور</label>\n' +
                '<select id="nation_id" name="nation_id[]" class="form-control">\n' +
                '<option></option>\n' +
                '@foreach($countries as $country)\n' +
                '<option value="{{ $country->id }}" {{ $educational->nation_id == $country->id ? 'selected' : '' }}>\n' +
                '{{ $country->name }}\n'+
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="province_id">استان</label>\n' +
                '<select id="province_id" name="province_id[]" class="form-control">\n' +
                '@foreach($states as $state)\n' +
                '<option value="{{ $state->id }}" {{ $educational->province_id == $state->id ? 'selected' : '' }}>\n' +
                '{{ $state->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '<input name="province_name[]" id="province_id" class="form-control d-none" value="{{ $educational->province_name }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="town_id">شهر</label>\n' +
                '<select id="town_id" name="town_id[]" class="form-control">\n' +
                '@foreach($cities as $city)\n' +
                '<option value="{{ $city->id }}" {{ $educational->town_id == $city->id ? 'selected' : '' }}>\n' +
                '{{ $city->name }}\n' +
                '</option>\n' +
                '@endforeach\n' +
                '</select>\n' +
                '<input name="town_name[]" id="town_id" class="form-control d-none" value="{{ $educational->town_name }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="entrance">ورود</label>\n' +
                '<input name="entrance[]" id="entrance" class="form-control" value="{{ $educational->entrance }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<label for="graduate">فراغت از تحصیل</label>\n' +
                '<input name="graduate[]" id="graduate" class="form-control" value="{{ $educational->graduate }}">\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="col-md-2">\n' +
                '<div class="form-group">\n' +
                '<div class="custom-control custom-checkbox my-4 mr-sm-2">\n' +
                '<input type="checkbox" class="custom-control-input" id="currently_studying" name="currently_studying[]" {{ $educational->currently_studying == 1 ? 'checked' : '' }}>\n' +
                '<label class="custom-control-label" for="currently_studying">در حال تحصیل</label>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '</div>\n' +
                '@endforeach';
            $('#showStudy').append(html);
        }
    });
</script>

The migration for table

public function up()
{
    Schema::create('educationals', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->bigInteger('user_id')->unsigned()->nullable();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        $table->bigInteger('grade_id')->unsigned()->nullable();
        $table->foreign('grade_id')->references('id')->on('grades')->onDelete('cascade');
        $table->string('field')->nullable();
        $table->bigInteger('institution_id')->unsigned()->nullable();
        $table->foreign('institution_id')->references('id')->on('institutions')->onDelete('cascade');
        $table->string('branch')->nullable();
        $table->string('institution_education')->nullable();
        $table->string('gpa')->nullable();
        $table->bigInteger('country_id')->unsigned()->nullable();
        $table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
        $table->bigInteger('state_id')->unsigned()->nullable();
        $table->foreign('state_id')->references('id')->on('states')->onDelete('cascade');
        $table->bigInteger('city_id')->unsigned()->nullable();
        $table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade');
        $table->string('state_name')->nullable();
        $table->string('city_name')->nullable();
        $table->string('entrance')->nullable();
        $table->string('graduate')->nullable();
        $table->boolean('currently_studying')->nullable();
        $table->timestamps();
    });
}

I used all five methods but none of them worked. And not stored in the database.