kkhicher1

kkhicher1

PHP Developer at Home

Member Since 6 Months Ago

Experience Points
2,790
Total
Experience

2,210 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
1
Lessons
Completed
Best Reply Awards
2
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
2,790 XP
May
26
4 days ago
Activity icon

Replied to How Do I Upload Images To My Heroku App In Laravel

did you check that your symlink folder in public folder created or not?

Activity icon

Replied to BelongsToMany Between Pivot Model And Regular Model

your ArticleSite haven't dossier_id column. You may try hasManyThrough Method in your model.

Check Full Article Here => https://laravel.com/docs/7.x/eloquent-relationships#has-many-through

May
22
1 week ago
Activity icon

Replied to Update OneToMany Relationship Table Data With Limit

from this

$count = 0;

        foreach ($user->pins as $pin) {
            if ($count == $request->no_of_pin) {
                if ($pin->status == 'available') {
                    $pin->user_id = $transfer_user->id;
                    $pin->save();
                    $count++;
                }
            }
        }
Activity icon

Replied to Update OneToMany Relationship Table Data With Limit

code work but i want eloquent way to done this task

May
21
1 week ago
Activity icon

Started a new Conversation Update OneToMany Relationship Table Data With Limit

I want to update oneToMany Reationship table data with limit and also where status is available....

$count = 0;

        foreach ($user->pins as $pin) {
            if ($count == $request->no_of_pin) {
                if ($pin->status == 'available') {
                    $pin->user_id = $transfer_user->id;
                    $pin->save();
                    $count++;
                }
            }
        }

May
18
1 week ago
Activity icon

Started a new Conversation Mood Off ! What You Do When It Happen?

as a developer i think its happen many time that your mood off to make a single module and write some code. I want to know how to overcome from this situation that i start coding again..

May
17
1 week ago
Activity icon

Awarded Best Reply on Laravel + Vue - Populate Select After API Call With Axios

you need to change your v-model of select

<select v-model="selected.person">

    <option v-for="person in persons" :value="person.id">
        {{ person.fullname_with_year }}
    </option>

</select>
<script>
    export default {

        data() {
            return {
                persons: [],
		selected:{
			person:''
		}
            }
        },

        mounted() {
            this.getPersons();
        },

        methods: {
            getPersons(){
                console.log('getPersons');
                axios.get('/api/persons/all')
                    .then((response) => {
                        console.log( response.data );
                        this.persons = response.data;

                    })
                    .catch( resonse => {
                        console.log('error');
                    })
            },
        }
    }
</script>

try this

Activity icon

Replied to Array To String Conversion

okay, but that is solution.... i want to know why that error return ....

Activity icon

Replied to Array To String Conversion

error return on this line =>

if (is_null($this->sponserTree->$columns[$i]))
Activity icon

Replied to Array To String Conversion

oh sorry,,,, that was typo error,,,,, now check

Activity icon

Replied to Laravel + Vue - Populate Select After API Call With Axios

you need to change your v-model of select

<select v-model="selected.person">

    <option v-for="person in persons" :value="person.id">
        {{ person.fullname_with_year }}
    </option>

</select>
<script>
    export default {

        data() {
            return {
                persons: [],
		selected:{
			person:''
		}
            }
        },

        mounted() {
            this.getPersons();
        },

        methods: {
            getPersons(){
                console.log('getPersons');
                axios.get('/api/persons/all')
                    .then((response) => {
                        console.log( response.data );
                        this.persons = response.data;

                    })
                    .catch( resonse => {
                        console.log('error');
                    })
            },
        }
    }
</script>

try this

Activity icon

Started a new Conversation Array To String Conversion

can anybody elaborate the below function throw error Array to string conversion but same thing work if i put in a variable.....

this throw error

// column name - id, user_id, left_1, left_2, right_1, right_2
$columns = Schema::getColumnListing('sponser_trees');
        if ($this->sponserTree != null) {
            for ($i = 2; $i <= 5; $i++) {
                if (is_null($this->sponserTree->$columns[$i])) {
                    return $columns[$i];
                }
            }
        } else {
            return 'left_1';
        }

its work fine;;;;

// column name - id, user_id, left_1, left_2, right_1, right_2
$columns = Schema::getColumnListing('sponser_trees');
        if ($this->sponserTree != null) {
            for ($i = 2; $i <= 5; $i++) {
                $col = (string) $columns[$i];
                if (is_null($this->sponserTree->$col)) {
                    return $col;
                }
            }
        } else {
            return 'left_1';
        }
May
16
2 weeks ago
Activity icon

Started a new Conversation Fire Parent Method On Child Component Value Change Vuejs

i want to fire a parent method on child component value change...

##parent component

<template>
  <div class="bg-gray-200 h-full">
    <header-view></header-view>
    <div class="px-32 py-6">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id nemo quam voluptates tenetur atque, similique odio quasi assumenda, quo porro deleniti eos nobis officia tempore, at harum odit. Illo, doloribus.</p>
    </div>
    <h2 class="text-2xl text-center about">Apply for Subsidy</h2>
    <div class="w-full h-full flex justify-center mt-16">
      <form class="w-full max-w-lg">
        <text-input id="name" placeholder="Enter Name" title="Name"></text-input>
        <text-input id="fathername" placeholder="Enter Father Name" title="Father Name"></text-input>
        <text-input id="phone" placeholder="Enter Active Mobile No" title="Mobile No"></text-input>
        <text-input id="aadhar" placeholder="Enter Aadhar No" title="Aadhar No"></text-input>
        <text-input id="accountno" placeholder="Enter Account No" title="Bank Account No"></text-input>
        <text-input
          id="ifsc"
          placeholder="Enter IFSC Code"
          title="Bank Branch IFSC Code"
          v-model="data.ifsc"
          @change="getIfscCode(data.ifsc)"
        ></text-input>
        <text-input id="accountname" placeholder="Enter Account Name" title="Bank Account Name"></text-input>
      </form>
    </div>
    <footer-view></footer-view>
  </div>
</template>

<script>
import HeaderView from "./header/Header";
import FooterView from "./footer/Footer";
import TextInput from "./form/TextInput";
export default {
  components: {
    HeaderView,
    FooterView,
    TextInput
  },
  data() {
    return {
      data: {
        name: "",
        ifsc: ""
      }
    };
  },
  created() {},
  methods: {
    getIfscCode(code) {
      axios
        .get(
          "https://mfapps.indiatimes.com/ET_Calculators/getBankDetailsByIfsc.htm?ifsccode=" +
            code +
            "&callback=objIFSC.getIfscData"
        )
        .then(res => {
          console.log(res.data);
        });
    }
  }
};
</script>

##child component

<template>
  <div class="flex flex-wrap mb-6">
    <div class="w-full px-3">
      <label
        class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
        :for="id"
      >{{title}}</label>
      <input
        class="appearance-none block w-full bg-gray-900 p-text-color border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white focus:border-gray-500 placeholder-blue-300"
        :id="id"
        type="text"
        :placeholder="placeholder"
        :value="inputvalue"
        @input="$emit('update', $event.target.value)"
      />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String
    },
    id: {
      type: String
    },
    placeholder: {
      type: String
    },
    inputvalue: undefined
  },
  model: {
    prop: "inputvalue",
    event: "update"
  }
};
</script>
May
10
2 weeks ago
Activity icon

Awarded Best Reply on Images In Public Folder.

very simple steps....

first create a temp. route to call a artisan command

Route::get('/symlink', function () {
    Artisan::call('storage:link');
});

then open browser and go to url -> http://example.com/symlink ========> only once

then check your public folder linked or not

hope its help..... if not reply this conversation

Activity icon

Replied to Images In Public Folder.

select a best answer so in feature other can get solution as fast as possible.

Activity icon

Replied to Https Routes Not Working

use code at the top of web.php

<?php 

use Illuminate\Support\Facades\URL;

if (env('APP_ENV') === 'production') {
    URL::forceScheme('https');
}

if you are using cloudflare try to add page rule

hope it help

Activity icon

Replied to Images In Public Folder.

very simple steps....

first create a temp. route to call a artisan command

Route::get('/symlink', function () {
    Artisan::call('storage:link');
});

then open browser and go to url -> http://example.com/symlink ========> only once

then check your public folder linked or not

hope its help..... if not reply this conversation

Activity icon

Replied to Test Single Pass But Fail When I Test All

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         colors="true">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
        <server name="CACHE_DRIVER" value="array"/>
        <server name="DB_CONNECTION" value="sqlite"/>
        <server name="DB_DATABASE" value=":memory:"/>
        <server name="MAIL_MAILER" value="array"/>
        <server name="QUEUE_CONNECTION" value="sync"/>
        <server name="DB_CONNECTION" value="mysql"/>
        <server name="DB_DATABASE" value="laravel7"/>
    </php>
</phpunit>

Activity icon

Replied to Form Request, Validation On Update

this is not developer friendly.... you should have only one request method on store and update ....... for this you can try

$on_update = $this->method() == "PUT" ? ','.$this->id : '';
return [
	'email'		=> 'required|unique:clients,id'.$on_update
];

this is will work both update and store method

Activity icon

Replied to Can Someone Help Me Out

@tomasosho => as per @guybrush_threepwood it's very simple process to store file into your storage folder or public folder.... 1st you have to decide where you want to store then implement the code...

May
09
3 weeks ago
Activity icon

Replied to Can Someone Help Me Out

first (in your controller method)

dd($request->avatar)  

if you get big string value then you need to decode your base64 image with php base64_decode function

base64_decode ( string $data [, bool $strict = false ] ); 

its a php function you can use in your controller...

Hope its help

Activity icon

Replied to Test Single Pass But Fail When I Test All

as i think..... when i run whole test total row will be 4. so in last method a_book_can_check_out_a_book_twice the Reservation::find(2) isn't exist because their may be id 3 and 4 exist ( when test all ) but on single test Reservation::find(2) return object that's why is success on single test? ? ? / ?

what you think?

Activity icon

Started a new Conversation Test Single Pass But Fail When I Test All

<?php

namespace Tests\Unit;

use App\Book;
use App\User;
use Tests\TestCase;
use App\Reservation;
use Exception;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class BookReservationTest extends TestCase
{
    use RefreshDatabase;
    /**
     * @test
     */
    public function a_book_can_be_checked_out()
    {
        // $book->checkout($user);
        $book = \factory(Book::class)->create();
        $user = \factory(User::class)->create();


        $book->checkout($user);

        $this->assertCount(1, Reservation::all());
        $this->assertEquals($user->id, Reservation::first()->user_id);
        $this->assertEquals($book->id, Reservation::first()->book_id);
        $this->assertEquals(now(), Reservation::first()->checked_out_at);
    }

    /**
     * @test
     */
    public function a_book_can_be_returned()
    {
        $book = \factory(Book::class)->create();
        $user = \factory(User::class)->create();

        $book->checkout($user);


        $book->checkin($user);

        $this->assertCount(1, Reservation::all());
        $this->assertEquals($user->id, Reservation::first()->user_id);
        $this->assertEquals($book->id, Reservation::first()->book_id);
        $this->assertEquals(now(), Reservation::first()->checked_in_at);
    }
    /**
     * @test
     */
    public function if_not_checked_out_exception_is_thrown()
    {
        $this->expectException(Exception::class);
        $book = \factory(Book::class)->create();
        $user = \factory(User::class)->create();

        $book->checkin($user);
    }
    /**
     * @test
     */
    public function a_book_can_check_out_a_book_twice()
    {
        $book = \factory(Book::class)->create();
        $user = \factory(User::class)->create();

        $book->checkout($user);
        $book->checkin($user);

        $book->checkout($user);


        $this->assertCount(2, Reservation::all());
        $this->assertEquals($user->id, Reservation::find(2)->user_id);
        $this->assertEquals($book->id, Reservation::find(2)->book_id);
        $this->assertNull(Reservation::find(2)->checked_in_at);
        $this->assertEquals(now(), Reservation::find(2)->checked_out_at);

        $book->checkin($user);

        $this->assertCount(2, Reservation::all());
        $this->assertEquals($user->id, Reservation::find(2)->user_id);
        $this->assertEquals($book->id, Reservation::find(2)->book_id);
        $this->assertNotNull(Reservation::find(2)->checked_in_at);
        $this->assertEquals(now(), Reservation::find(2)->checked_in_at);
    }
}

when i run test a_book_can_check_out_a_book_twice with filter it pass but when i run phpunit its fail and return error

1) Tests\Unit\BookReservationTest::a_book_can_check_out_a_book_twice
ErrorException: Trying to get property 'user_id' of non-object
Apr
18
1 month ago
Activity icon

Replied to How To Store Image In Laravel 7.4.0?

very simple----

save to storage

if ($request->hasFile('product_photo')) {
            // Get filename with extension            
            $filenameWithExt = $request->file('product_photo')->getClientOriginalName();
            // Get just filename
            $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
            // Get just ext
            $extension = $request->file('product_photo')->getClientOriginalExtension();
            //Filename to store
            $fileNameToStore = $filename . '_' . time() . '.' . $extension;
            // Upload Image
            $path = $request->file('product_photo')->storeAs('public/product-photos', $fileNameToStore);
        }

to store in db

$product = Model::create([
	'product_photo_name' => $fileNameToStore,
]);
Activity icon

Replied to How To Use DiffForHumans() In Vue

I got the solution that you can use anywhere with casting attribute. Check Code below

<?php

namespace App\Casts;

use Carbon\Carbon;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class CreateAtCast implements CastsAttributes
{
    /**
     * Transform the attribute from the underlying model values.
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  mixed  $value
     * @param  array  $attributes
     * @return mixed
     */
    public function get($model, string $key, $value, array $attributes)
    {
        $date = Carbon::parse($value)->diffForHumans();
        return $date;
    }

    /**
     * Transform the attribute to its underlying model values.
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  mixed  $value
     * @param  array  $attributes
     * @return array
     */
    public function set($model, string $key, $value, array $attributes)
    {
        return $value;
    }
}

in Modal


<?php

namespace App;

use App\Casts\CreateAtCast;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    protected $casts = [
        'email_verified_at' => 'datetime',
        'created_at'        => CreateAtCast::class,
    ];

    protected $dates = ['created_at', 'updated_at'];
}


in vue template just use - user.create_at

Apr
14
1 month ago
Activity icon

Replied to Checkbox Custom Component Value Not Updating VUE JS

I tried this temp. solution. is it okay?

<template>
  <div>
    <div class="form-group" v-if="type != 'checkbox'">
      <label v-bind:for="id">{{labelText}}</label>
      <input
        v-bind:type="type"
        class="form-control"
        v-bind:id="id"
        v-bind:placeholder="placeholder"
        autocomplete="off"
        :value="inputvalue"
        @input="$emit('update', $event.target.value)"
      />
      <small class="form-text text-danger" v-if="errorMsg">{{errorMsg}}</small>
    </div>

    <div class="form-group ml-4 form-check-inline" v-if="type == 'checkbox'">
      <input
        v-bind:id="id"
        class="form-check-input"
        v-bind:type="type"
        :value="checkboxvalue"
        @change="onCheckboxChange"
      />
      <label class="form-check-label" v-bind:for="id">{{labelText}}</label>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    id: String,
    labelText: String,
    type: String,
    placeholder: String,
    errorMsg: String,
    checkboxvalue: Number,
    inputvalue: undefined
  },
  model: {
    prop: "inputvalue",
    event: "update"
  },
  methods: {
    onCheckboxChange(e) {
      if (e.target.checked) {
        this.$emit("update", e.target.value);
      } else {
        this.$emit("update", null);
      }
    }
  }
};
</script>
Apr
13
1 month ago
Activity icon

Replied to Checkbox Custom Component Value Not Updating VUE JS

I tried both but result same..

Apr
12
1 month ago
Activity icon

Started a new Conversation Checkbox Custom Component Value Not Updating VUE JS

I make reusable checkbox custom element with vue. but i got problem. when i select i got the value but when uncheck instant my value not change to default.

My Custom Input Vue

<template>
  <div>
    <div class="form-group" v-if="type != 'checkbox'">
      <label v-bind:for="id">{{labelText}}</label>
      <input
        v-bind:type="type"
        class="form-control"
        v-bind:id="id"
        v-bind:placeholder="placeholder"
        autocomplete="off"
        :value="inputvalue"
        @input="$emit('update', $event.target.value)"
      />
      <small class="form-text text-danger" v-if="errorMsg">{{errorMsg}}</small>
    </div>

    <div class="form-group ml-4 form-check-inline" v-if="type == 'checkbox'">
      <input
        v-bind:id="id"
        class="form-check-input"
        v-bind:type="type"
        :value="checkboxvalue"
        @input="$emit('update', $event.target.value)"
      />
      <label class="form-check-label" v-bind:for="id">{{labelText}}</label>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    id: String,
    labelText: String,
    type: String,
    placeholder: String,
    errorMsg: String,
    checkboxvalue: undefined,
    inputvalue: undefined
  },
  model: {
    prop: "inputvalue",
    event: "update"
  },
  methods: {}
};
</script>

My Parent Vue

<template>
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-12">
        <button
          class="btn btn-primary btn-round"
          data-toggle="modal"
          data-target="#add-role"
        >Add New Role</button>
        <button
          class="btn btn-primary btn-round"
          data-toggle="modal"
          data-target="#add-permission"
        >Add New Permission</button>

        <!-- modals -->
        <!-- role modal -->
        <pop-modal
          title="Add New Role"
          id="add-role"
          btn-title="Save Role"
          v-bind:saveData="saveRole"
        >
          <input-modal
            id="name"
            label-text="Role Name"
            placeholder="Enter Role Name"
            type="text"
            v-model="data.name"
          ></input-modal>
          <p>
            <strong>Select Permission</strong>
          </p>
          <input-modal
            v-for="(permission, index) in permissions"
            :id="`permission-input-`+ permission.id"
            :label-text="permission.name"
            type="checkbox"
            :checkboxvalue="permission.id"
            v-model="data.ids[index]"
            :key="permission.id"
          ></input-modal>
        </pop-modal>
        <!-- permission Modal -->
        <pop-modal title="Add New Permission" id="add-permission" v-bind:saveData="savePermission">
          <input-modal
            id="name"
            label-text="Permission Name"
            placeholder="Enter Permission Name"
            type="text"
          ></input-modal>
        </pop-modal>
      </div>
      <div class="col-md-6">
        <h3 class="border-bottom border-primary">Roles</h3>
        <div class>
          <table class="table table-hover table-bordered">
            <tr>
              <th>Role Name</th>
              <th>Guard</th>
              <th>Actions</th>
            </tr>
            <tr v-for="role in roles">
              <td>{{role.name}}</td>
              <td>{{role.guard_name}}</td>
              <td>
                <button class="btn btn-warning btn-sm">Edit</button>
                <button class="btn btn-danger btn-sm">Delete</button>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="col-md-6">
        <h3 class="border-bottom border-primary">Permissions</h3>
        <div class>
          <table class="table table-hover table-bordered">
            <tr>
              <th>Permission Name</th>
              <th>Guard</th>
              <th>Actions</th>
            </tr>
            <tr v-for="permission in permissions">
              <td>{{permission.name}}</td>
              <td>{{permission.guard_name}}</td>
              <td>
                <button class="btn btn-warning btn-sm">Edit</button>
                <button class="btn btn-danger btn-sm">Delete</button>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import PopModal from "../modals/popup-modal";
import InputModal from "../modals/input.vue";
export default {
  components: {
    PopModal,
    InputModal
  },
  data() {
    return {
      roles: [],
      permissions: [],
      data: {
        name: "",
        ids: []
      }
    };
  },
  created() {
    this.fetchRoles();
    this.fetchPermissions();
  },
  methods: {
    fetchRoles() {
      axios.get("/admin/fetch/roles").then(res => (this.roles = res.data));
    },
    fetchPermissions() {
      axios
        .get("/admin/fetch/permissions")
        .then(res => (this.permissions = res.data));
    },
    saveRole() {
      // axios.post("/admin/add-role", this.data).then(res => {
      //   console.log(res.data);
      // });
      console.log(this.data);
    },
    savePermission() {
      // axios.post("/admin/add-role", this.data).then(res => {
      //   console.log(res.data);
      // });
      console.log("Permission Saved");
    }
  }
};
</script>

Check photo attachment -

https://ibb.co/fp95cx4

https://ibb.co/CmJnf0v

Activity icon

Replied to Micro Services With Laravel

when ever you publish video on any platform about microservices. just send me tutorials link. :)

Apr
06
1 month ago
Activity icon

Replied to Micro Services With Laravel

I never take any course here. I just learn from books pdf, documentation, some youtube video and issue discussed with expert like you.

So i thing that.

Activity icon

Replied to Micro Services With Laravel

Money is not everything. Grow the community.

If you make videos on this topic and upload on udmey i will buy your course.

Activity icon

Replied to Micro Services With Laravel

Ya you are right bro. So i said to make tutorials on this topic because on YouTube there no related video are.

Activity icon

Replied to Micro Services With Laravel

Not just for speed i need to decide to separate some part of my app so whenever i need to to change that part my other app part work properly and many more thing in my mind

Activity icon

Replied to Micro Services With Laravel

Any Video tutorials on this particular topic?

Activity icon

Replied to Micro Services With Laravel

Can you create some videos on this topic.

Thanks in Advance...

Activity icon

Started a new Conversation Micro Services With Laravel

is there any tutorials to create microservices with Laravel? If you have any youtube channel please create it from scratch.

I Waiting for your response.

Mar
25
2 months ago
Activity icon

Replied to Custom Validation Rule For Update

on insert its working fine but when i update it return - Section name in this class already exist ---

Activity icon

Started a new Conversation Custom Validation Rule For Update

i want to make rule for both insert and update with unique name of section.... check code below

<?php

namespace App\Rules;

use App\Section;
use Illuminate\Contracts\Validation\Rule;

class SectionNameRule implements Rule
{
    protected $grade_id;
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct($grade_id)
    {
        $this->grade_id = $grade_id;
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        $section_count = Section::where('grade_id', $this->grade_id)->where('name', $value)->count();

        if ($section_count == 0) {
            return true;
        }
        return false;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'Section name in this class already exist';
    }
}
Mar
24
2 months ago
Activity icon

Awarded Best Reply on Insert Multiple Record In Laravel Via Vue Js

I got the solution so i posted here----

<template>
  <div>
    <div class="row">
      <div class="col-md-12">
        <h1>Report Cards</h1>

        <div class="col-md-12 form-inline">
          <div class="form-group">
            <label>Select Class</label>
            <select
              class="form-control"
              v-model="temp_grade_id"
              @change="getSection(temp_grade_id)"
            >
              <option v-for="grade in grades" :value="grade.id">{{grade.name}}</option>
            </select>
          </div>
          <div class="mr-4"></div>
          <div class="form-group">
            <label>Select Section</label>
            <select
              class="form-control"
              @change="getStudent(temp_section_id)"
              v-model="temp_section_id"
            >
              <option v-for="section in sections" :value="section.id">{{section.name}}</option>
            </select>
          </div>
        </div>

        <div class="table-responsive">
          <table class="table table-bordered">
            <tr>
              <th>Name</th>
              <th>Hindi</th>
              <th>English</th>
              <th>Math</th>
              <th>Sci</th>
              <th>SS</th>
              <th>Sankrit</th>
              <th>Phy. Edu.</th>
              <th>GK</th>
              <th>Writing</th>
              <th>Attendance</th>
              <th>Position</th>
              <th>Message</th>
            </tr>
            <tr v-if="student_lists.length === 0">
              <td colspan="12">No Student</td>
            </tr>
            <tr v-for="(student, index) in student_lists">
              {{setStudentId(index, student.id)}}
              <td>{{student.user.name}}</td>
              <td>
                <input type="text" class="form-control" v-model="records[index].hindi" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].english" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].math" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].sci" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].ss" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].sanskrit" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].phy_edu" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].gk" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].writing" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].attendance" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].position" />
              </td>
              <td>
                <textarea class="form-control" v-model="records[index].message"></textarea>
              </td>
            </tr>
          </table>
          <button
            v-if="student_lists.length !== 0"
            class="btn btn-primary btn-rounded"
            @click="sendReport"
          >Submit Report</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      temp_grade_id: 0,
      temp_section_id: 0,
      grades: [],
      sections: [],
      lists: [],
      student_lists: [],
      records: [],
      tempID: 0,
      newFormType: 1
    };
  },
  created() {
    this.fetchGrades();
  },
  methods: {
    setStudentId(index, student_id) {
      this.records[index].student_id = student_id;
    },
    fetchGrades() {
      axios.get("/report-card/fetch/grades").then(res => {
        this.grades = res.data;
      });
    },
    getSection() {
      axios
        .get("/report-card/fetch/section/" + this.temp_grade_id)
        .then(res => (this.sections = res.data));
    },
    getStudent() {
      axios
        .get("/report-card/fetch/student/" + this.temp_section_id)
        .then(res => {
          this.records = [];
          var data = res.data;
          for (let index = 0; index < res.data.length; index++) {
            this.addRow();
            if (data[index].reportcard != null) {
              this.records[index].id = data[index].reportcard.id;
              this.records[index].student_id =
                data[index].reportcard.student_id;
              this.records[index].hindi = data[index].reportcard.hindi;
              this.records[index].english = data[index].reportcard.english;
              this.records[index].math = data[index].reportcard.math;
              this.records[index].sci = data[index].reportcard.sci;
              this.records[index].ss = data[index].reportcard.ss;
              this.records[index].sanskrit = data[index].reportcard.sanskrit;
              this.records[index].phy_edu = data[index].reportcard.phy_edu;
              this.records[index].gk = data[index].reportcard.gk;
              this.records[index].writing = data[index].reportcard.writing;
              this.records[index].attendance =
                data[index].reportcard.attendance;
              this.records[index].position = data[index].reportcard.position;
              this.records[index].message = data[index].reportcard.message;
            }
          }
          this.student_lists = res.data;
        });
    },
    sendReport() {
      axios.post("report-card", this.records).then();
    },
    addRow() {
      this.records.push({
        id: "",
        student_id: null,
        hindi: null,
        english: null,
        math: null,
        sci: null,
        ss: null,
        sanskrit: null,
        phy_edu: null,
        gk: null,
        writing: null,
        attendance: null,
        position: null,
        message: null
      });
    }
  }
};
</script>
Activity icon

Replied to Insert Multiple Record In Laravel Via Vue Js

I got the solution so i posted here----

<template>
  <div>
    <div class="row">
      <div class="col-md-12">
        <h1>Report Cards</h1>

        <div class="col-md-12 form-inline">
          <div class="form-group">
            <label>Select Class</label>
            <select
              class="form-control"
              v-model="temp_grade_id"
              @change="getSection(temp_grade_id)"
            >
              <option v-for="grade in grades" :value="grade.id">{{grade.name}}</option>
            </select>
          </div>
          <div class="mr-4"></div>
          <div class="form-group">
            <label>Select Section</label>
            <select
              class="form-control"
              @change="getStudent(temp_section_id)"
              v-model="temp_section_id"
            >
              <option v-for="section in sections" :value="section.id">{{section.name}}</option>
            </select>
          </div>
        </div>

        <div class="table-responsive">
          <table class="table table-bordered">
            <tr>
              <th>Name</th>
              <th>Hindi</th>
              <th>English</th>
              <th>Math</th>
              <th>Sci</th>
              <th>SS</th>
              <th>Sankrit</th>
              <th>Phy. Edu.</th>
              <th>GK</th>
              <th>Writing</th>
              <th>Attendance</th>
              <th>Position</th>
              <th>Message</th>
            </tr>
            <tr v-if="student_lists.length === 0">
              <td colspan="12">No Student</td>
            </tr>
            <tr v-for="(student, index) in student_lists">
              {{setStudentId(index, student.id)}}
              <td>{{student.user.name}}</td>
              <td>
                <input type="text" class="form-control" v-model="records[index].hindi" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].english" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].math" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].sci" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].ss" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].sanskrit" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].phy_edu" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].gk" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].writing" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].attendance" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="records[index].position" />
              </td>
              <td>
                <textarea class="form-control" v-model="records[index].message"></textarea>
              </td>
            </tr>
          </table>
          <button
            v-if="student_lists.length !== 0"
            class="btn btn-primary btn-rounded"
            @click="sendReport"
          >Submit Report</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      temp_grade_id: 0,
      temp_section_id: 0,
      grades: [],
      sections: [],
      lists: [],
      student_lists: [],
      records: [],
      tempID: 0,
      newFormType: 1
    };
  },
  created() {
    this.fetchGrades();
  },
  methods: {
    setStudentId(index, student_id) {
      this.records[index].student_id = student_id;
    },
    fetchGrades() {
      axios.get("/report-card/fetch/grades").then(res => {
        this.grades = res.data;
      });
    },
    getSection() {
      axios
        .get("/report-card/fetch/section/" + this.temp_grade_id)
        .then(res => (this.sections = res.data));
    },
    getStudent() {
      axios
        .get("/report-card/fetch/student/" + this.temp_section_id)
        .then(res => {
          this.records = [];
          var data = res.data;
          for (let index = 0; index < res.data.length; index++) {
            this.addRow();
            if (data[index].reportcard != null) {
              this.records[index].id = data[index].reportcard.id;
              this.records[index].student_id =
                data[index].reportcard.student_id;
              this.records[index].hindi = data[index].reportcard.hindi;
              this.records[index].english = data[index].reportcard.english;
              this.records[index].math = data[index].reportcard.math;
              this.records[index].sci = data[index].reportcard.sci;
              this.records[index].ss = data[index].reportcard.ss;
              this.records[index].sanskrit = data[index].reportcard.sanskrit;
              this.records[index].phy_edu = data[index].reportcard.phy_edu;
              this.records[index].gk = data[index].reportcard.gk;
              this.records[index].writing = data[index].reportcard.writing;
              this.records[index].attendance =
                data[index].reportcard.attendance;
              this.records[index].position = data[index].reportcard.position;
              this.records[index].message = data[index].reportcard.message;
            }
          }
          this.student_lists = res.data;
        });
    },
    sendReport() {
      axios.post("report-card", this.records).then();
    },
    addRow() {
      this.records.push({
        id: "",
        student_id: null,
        hindi: null,
        english: null,
        math: null,
        sci: null,
        ss: null,
        sanskrit: null,
        phy_edu: null,
        gk: null,
        writing: null,
        attendance: null,
        position: null,
        message: null
      });
    }
  }
};
</script>
Mar
22
2 months ago
Activity icon

Started a new Conversation Insert Multiple Record In Laravel Via Vue Js

I want to insert multiple record in one time. i write but this too messy to solve problem on controller side. check the code of vuejs below and suggest me

<template>
  <div>
    <div class="row">
      <div class="col-md-12">
        <h1>Report Cards</h1>

        <div class="col-md-2">
          <div class="form-group">
            <label>Select Class</label>
            <select
              class="form-control"
              v-model="temp_grade_id"
              @change="getSection(temp_grade_id)"
            >
              <option v-for="grade in grades" :value="grade.id">{{grade.name}}</option>
            </select>
          </div>
        </div>
        <div class="col-md-2">
          <div class="form-group">
            <label>Select Class</label>
            <select
              class="form-control"
              @change="getStudent(temp_section_id)"
              v-model="temp_section_id"
            >
              <option v-for="section in sections" :value="section.id">{{section.name}}</option>
            </select>
          </div>
        </div>

        <div class="table-responsive">
          <table class="table table-bordered">
            <tr>
              <th>Name</th>
              <th>Hindi</th>
              <th>English</th>
              <th>Math</th>
              <th>Sci</th>
              <th>SS</th>
              <th>Sankrit</th>
              <th>Phy. Edu.</th>
              <th>GK</th>
              <th>Writing</th>
              <th>Attendance</th>
              <th>Position</th>
              <th>Message</th>
            </tr>
            <tr v-if="student_lists.length === 0">
              <td colspan="12">No Student</td>
            </tr>
            <tr v-for="(student, index) in student_lists">
              {{setStudentId(index, student.id)}}
              <td>{{student.user.name}}</td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.hindi[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.english[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.math[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.sci[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.ss[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.sanskrit[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.phy_edu[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.gk[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.writing[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.attendance[index]" />
              </td>
              <td>
                <input type="text" class="form-control" v-model="reportcard.position[index]" />
              </td>
              <td>
                <textarea class="form-control" v-model="reportcard.message[index]"></textarea>
              </td>
            </tr>
          </table>
          <button
            v-if="student_lists.length !== 0"
            class="btn btn-primary btn-rounded"
            @click="sendReport"
          >Submit Report</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      temp_grade_id: 0,
      temp_section_id: 0,
      grades: [],
      sections: [],
      lists: [],
      student_lists: [],
      reportcard: {
        id: [],
        student_id: [],
        hindi: [],
        english: [],
        math: [],
        sci: [],
        ss: [],
        sanskrit: [],
        phy_edu: [],
        gk: [],
        writing: [],
        attendance: [],
        position: [],
        message: []
      },
      tempID: 0,
      newFormType: 1
    };
  },
  created() {
    this.fetchGrades();
  },
  methods: {
    setStudentId(index, student_id) {
      this.reportcard.student_id[index] = student_id;
    },
    fetchGrades() {
      axios.get("/report-card/fetch/grades").then(res => {
        this.grades = res.data;
      });
    },
    getSection() {
      axios
        .get("/report-card/fetch/section/" + this.temp_grade_id)
        .then(res => (this.sections = res.data));
    },
    getStudent() {
      axios
        .get("/report-card/fetch/student/" + this.temp_section_id)
        .then(res => (this.student_lists = res.data));
    },
    sendReport() {
      axios.post("report-card", this.reportcard).then(res => {
        console.log(res.data);
      });
    }
  }
};
</script>
Mar
20
2 months ago
Activity icon

Replied to Upload Image Via Vue In Laravel Project

Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0 Array ( )

i got error after submit form

Activity icon

Started a new Conversation Upload Image Via Vue In Laravel Project

Hi, How i can add image with vue axios...

check code and suggest me changes.....

<template>
  <div>
    <div class="modal fade" id="studentmodal" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLongTitle">Add New Student</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <div class="modal-body">
            <form action="#" method="post">
              <div class="form-group">
                <label for="name">Name</label>
                <input type="text" name="name" class="form-control" v-model="student.name" />
              </div>
              <div class="form-group">
                <label for="email">Email</label>
                <input type="email" name="email" class="form-control" v-model="student.email" />
              </div>
              <div class="form-group" v-if="newFormType==1">
                <label for="password">Password</label>
                <input type="text" name="password" class="form-control" v-model="student.password" />
              </div>
              <div class="form-group">
                <label for="gender">Gender</label>
                <select class="form-control" name="gender" id="gender" v-model="student.gender">
                  <option value="male">Male</option>
                  <option value="female">Female</option>
                  <option value="other">Other</option>
                </select>
              </div>
              <div class="form-group">
                <label for="gender">Class</label>
                <select
                  class="form-control"
                  name="gender"
                  id="gender"
                  v-model="student.grade_id"
                  @change="fetchSection(student.grade_id)"
                >
                  <option v-for="grade in grades" :value="grade.id">{{grade.name}}</option>
                </select>
              </div>
              <div class="form-group">
                <label for="gender">Section</label>
                <select class="form-control" name="gender" id="gender" v-model="student.section_id">
                  <option v-for="section in sections" :value="section.id">{{section.name}}</option>
                </select>
              </div>
              <div class="form-group">
                <label for="phone">Roll No</label>
                <input type="text" name="phone" class="form-control" v-model="student.roll_no" />
              </div>
              <div class="form-group">
                <label for="phone">Phone</label>
                <input type="text" name="phone" class="form-control" v-model="student.phone" />
              </div>
              <div class="form-group">
                <label for="dob">DOB</label>
                <input type="date" name="dob" class="form-control" v-model="student.dob" />
              </div>
              <div class="form-group">
                <label for="c_add">Current Address</label>
                <input type="text" name="c_add" class="form-control" v-model="student.c_add" />
              </div>
              <div class="form-group">
                <label for="p_add">Permanent Address</label>
                <input type="text" name="p_add" class="form-control" v-model="student.p_add" />
              </div>
              <div class="form-group">
                <label for="profile_picture">Profile Picture</label>
                <div v-if="!student.profile_picture">
                  <input type="file" @change="onFileChange" />
                </div>
                <div v-else>
                  <img :src="student.profile_picture" />
                  <button @click="removeImage">Remove image</button>
                </div>
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button
              type="button"
              class="btn btn-secondary"
              data-dismiss="modal"
              @click="onClose()"
            >Close</button>
            <button
              type="button"
              class="btn btn-primary"
              data-dismiss="modal"
              @click="createStudent"
            >{{button_text}}</button>
          </div>
        </div>
      </div>
    </div>
    <delete-modal v-bind:deleteItem="deleteItem"></delete-modal>

    <div class="row">
      <div class="col-md-12">
        <button
          class="btn btn-primary btn-rounded"
          data-toggle="modal"
          data-target="#studentmodal"
        >Add New Student</button>
        <h1>Students</h1>
        <div class="table-responsive">
          <table class="table table-borderd">
            <tr>
              <th>Name</th>
              <th>Phone</th>
              <th>Actions</th>
            </tr>
            <tr v-if="lists.length === 0">
              <td colspan="3">No Students added yet</td>
            </tr>
            <tr v-for="list in lists">
              <td>{{list.user.name}}</td>
              <td>{{list.phone}}</td>
              <td>
                <button
                  class="btn btn-warning btn-sm btn-rounded"
                  data-target="#studentmodal"
                  data-toggle="modal"
                  @click="editTeacher(list)"
                >Edit</button>
                <button
                  class="btn btn-danger btn-sm btn-rounded"
                  data-target="#deleteModal"
                  data-toggle="modal"
                  @click="wantToDelete(list.id)"
                >Delete</button>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      grades: [],
      lists: [],
      sections: [],
      student: {
        id: 0,
        name: "",
        email: "",
        password: "",
        profile_picture: "",
        grade_id: "",
        section_id: "",
        roll_no: "",
        gender: "",
        phone: "",
        dob: "",
        c_add: "",
        p_add: ""
      },
      newFormType: 1,
      tempID: 0,
      button_text: "Create",
      config: { headers: { "Content-Type": "multipart/form-data" } }
    };
  },
  created() {
    this.fetchData();
    this.fetchGrades();
  },
  methods: {
    removeImage(e) {
      this.image = "";
    },
    onFileChange(e) {
      var files = e.target.files || e.dataTransfer.files;
      if (!files.length) return;
      this.createImage(files[0]);
    },
    createImage(file) {
      var image = new Image();
      var reader = new FileReader();
      var vm = this;

      reader.onload = e => {
        vm.image = e.target.result;
      };
      reader.readAsDataURL(file);
    },
    fetchData() {
      axios.get("/student/fetch").then(res => {
        this.lists = res.data;
      });
    },
    fetchGrades() {
      axios.get("/grades/fetch").then(res => {
        this.grades = res.data;
      });
    },
    fetchSection(grade_id) {
      axios
        .get("/student/fetch-grade-section/" + this.student.grade_id)
        .then(res => {
          this.sections = res.data;
        });
    },
    createStudent() {
      if (this.newFormType) {
        var method = axios.post;
        var url = "student";
      } else {
        var url = "student/" + this.student.id;
        var method = axios.put;
      }
      method(url, this.student, this.config).then(res => {
        console.log(res.data);
        this.fetchData();
      });
    },
    editStudent(student) {
      this.button_text = "Update";
    },
    wantToDelete(id) {
      this.tempID = id;
    },
    deleteItem() {
      axios.delete("/student/" + this.tempID).then(this.fetchData());
    },
    onClose() {
      this.newFormType = 1;
      this.button_text = "Create";
    }
  }
};
</script>
Mar
19
2 months ago
Activity icon

Replied to Get Relationship Of Relationship Data In Laravel Vue

thanks tykus problem solved

return Subject::with('teacher.user')->get();

Vue

 <td>{{list.teacher.user.name}}</td>
Activity icon

Started a new Conversation Get Relationship Of Relationship Data In Laravel Vue

Hi,

i want to get the data of user that is relation with teacher and teacher is relation with subject,.

now i want to get data in subject vue file with user name. but i just get teacher data only.

sending data

return Subject::with('teacher')->get();

migrations


users->
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();

teachers->

$table->id();
            $table->unsignedBigInteger('user_id');
            $table->enum('gender', ['male', 'female', 'other']);
            $table->string('phone');
            $table->dateTime('dob');
            $table->mediumText('c_add');
            $table->mediumText('p_add');
            $table->timestamps();

subjects->

$table->id();
            $table->string('name');
            $table->string('description');
            $table->unsignedBigInteger('teacher_id');
            $table->timestamps();