kkhicher1

kkhicher1

PHP Developer at Home

Member Since 3 Months Ago

Experience Points
680
Total
Experience

4,320 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
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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
680 XP
Feb
12
2 weeks ago
Activity icon

Started a new Conversation Based On 2 Columns Diff Value 3rd Column Value Can Be Same

I'm working on School management project. I want to add student information with class, section and roll no. i facing issue of unique value of roll no. check table below

| class | section | roll no | should be | |:------- :|:--------- :|:---------:|:--------------: | | 1 | 1 | 1 | store | | 2 | 1 | 1 | store | | 3 | 2 | 1 | store | | 1 | 2 | 1 | store | | 1 | 1 | 1 | return error | | 2 | 1 | 1 | return error |

i want add code in controller...

Activity icon

Replied to Store Or Update Enum Value

@singhwithlaravel @bohannon @a4ashraf

everything is ok.... i just forgot to add fillable property in student model.

Code was more than ok.... :)

Thanks for help

Activity icon

Replied to Slug For Hindi Words

thanks i get solution

<?php

namespace App\Functions;

class Slug
{
    /**
     * @param $title
     * @param $model = App\Category, App\Post, App\User .............
     * @param int $id
     * @return string
     * @throws \Exception
     */
    public static function createSlug($title, $model, $id = 0)
    {
        // Normalize the title
        $slug = str_slug($title);
        // Get any that could possibly be related.
        // This cuts the queries down by doing it once.
        $allSlugs = self::getRelatedSlugs($slug, $model, $id);
        // If we haven't used it before then we are all good.
        if (!$allSlugs->contains('slug', $slug)) {
            return $slug;
        }
        // Just append numbers like a savage until we find not used.
        for ($i = 1; $i <= 50; $i++) {
            $sufix = \substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 4);
            $newSlug = $slug . '-' . $sufix;
            if (!$allSlugs->contains('slug', $newSlug)) {
                return $newSlug;
            }
        }
        throw new \Exception('Can not create a unique slug');
    }

    public static function makeHindiSlug($string, $separator = '-')
    {
        if (is_null($string)) {
            return "";
        }

        // Remove spaces from the beginning and from the end of the string
        $string = trim($string);

        // Remove multiple dashes or whitespaces
        $string = preg_replace("/[\s-]+/", " ", $string);

        // Convert whitespaces and underscore to the given separator
        $string = preg_replace("/[\s_]/", $separator, $string);

        return $string;
    }



    protected static function getRelatedSlugs($slug, $model, $id = 0)
    {
        return $model::select('slug')->where('slug', 'like', $slug . '%')
            ->where('id', '<>', $id)
            ->get();
    }
}
Feb
11
2 weeks ago
Activity icon

Replied to Store Or Update Enum Value

Form Submitted Data while updating

array:14 [▼
  "_token" => "tDSjF09c5B8LoFujSfc9OEZ1hnQlOZiNUWF7VGEp"
  "_method" => "PUT"
  "name" => "roll no 5"
  "email" => "[email protected]"
  "roll_number" => "5"
  "phone" => "1234567890"
  "gender" => "female"
  "dateofbirth" => "2020-02-10"
  "current_address" => "vsdfsd"
  "permanent_address" => "fdsfsdf"
  "religious" => "sikh"
  "caste" => "sc"
  "class_id" => "2"
  "parent_id" => "1"
]
Activity icon

Replied to Store Or Update Enum Value

public function up()
    {
        Schema::create('students', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('parent_id');
            $table->unsignedBigInteger('class_id');
            $table->unsignedBigInteger('roll_number');
            $table->enum('gender', ['male', 'female', 'other']);
            $table->string('phone');
            $table->date('dateofbirth');
            $table->string('current_address');
            $table->string('permanent_address');
            $table->enum('religious', ['hindu', 'muslim', 'sikh' , 'christian'])->default('hindu');
            $table->enum('caste', ['gen', 'obc', 'bc', 'sc', 'st'])->default('gen');
            $table->timestamps();
        });
    }
Activity icon

Started a new Conversation Slug For Hindi Words

I working on a website that is on laravel. I getting issue when admin add a hindi word.

Word - कोरोनावायरस URL - https://wordkosh.com/hindi-english/करनवयरस-meaning-english

Hindi Slug Code -

<?php

namespace App\Functions;

class Slug
{
    /**
     * @param $title
     * @param $model = App\Category, App\Post, App\User .............
     * @param int $id
     * @return string
     * @throws \Exception
     */
    public static function createSlug($title, $model, $id = 0)
    {
        // Normalize the title
        $slug = str_slug($title);
        // Get any that could possibly be related.
        // This cuts the queries down by doing it once.
        $allSlugs = self::getRelatedSlugs($slug, $model, $id);
        // If we haven't used it before then we are all good.
        if (!$allSlugs->contains('slug', $slug)) {
            return $slug;
        }
        // Just append numbers like a savage until we find not used.
        for ($i = 1; $i <= 50; $i++) {
            $sufix = \substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 4);
            $newSlug = $slug . '-' . $sufix;
            if (!$allSlugs->contains('slug', $newSlug)) {
                return $newSlug;
            }
        }
        throw new \Exception('Can not create a unique slug');
    }

    public static function makeHindiSlug($string, $separator = '-')
    {
        if (is_null($string)) {
            return "";
        }

        // Remove spaces from the beginning and from the end of the string
        $string = trim($string);

        // Lower case everything 
        // using mb_strtolower() function is important for non-Latin UTF-8 string | more info: http://goo.gl/QL2tzK
        $string = mb_strtolower($string, "UTF-8");;

        // Make alphanumeric (removes all other characters)
        // this makes the string safe especially when used as a part of a URL
        // this keeps latin characters and arabic charactrs as well
        $string = preg_replace("/[^a-z0-9_\s-अआइईउऊएऐओऔअंअःऋॠऌॡकखगघङचछजझञटठडढणड़ढ़तथदधनपफबभमयरलवशषसहक्षत्रज्ञ]/u", "", $string);

        // Remove multiple dashes or whitespaces
        $string = preg_replace("/[\s-]+/", " ", $string);

        // Convert whitespaces and underscore to the given separator
        $string = preg_replace("/[\s_]/", $separator, $string);

        return $string;
    }



    protected static function getRelatedSlugs($slug, $model, $id = 0)
    {
        return $model::select('slug')->where('slug', 'like', $slug . '%')
            ->where('id', '<>', $id)
            ->get();
    }
}
Activity icon

Replied to Store Or Update Enum Value

HTML Code

<div class="md:w-2/3 block text-gray-600 font-bold">
                    <div class="relative">
                        <select name="religious"
                            class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
                            id="grid-state">
                            <option value="">--Select Religious--</option>
                            <option value="hindu">Hindu</option>
                            <option value="muslim">Muslim</option>
                            <option value="sikh">Sikh</option>
                            <option value="christian">Christian</option>
                        </select>
                        <div
                            class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>
            <div class="md:flex md:items-center mb-6">
                <div class="md:w-1/3">
                    <label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4">
                        Caste
                    </label>
                </div>
                <div class="md:w-2/3 block text-gray-600 font-bold">
                    <div class="relative">
                        <select name="caste"
                            class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
                            id="grid-state">
                            <option value="">--Select Caste--</option>
                            <option value="gen">Gen</option>
                            <option value="obc">OBC</option>
                            <option value="bc">BC</option>
                            <option value="sc">SC</option>
                            <option value="st">ST</option>
                        </select>
                        <div
                            class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>
Activity icon

Replied to Store Or Update Enum Value

<div class="md:w-2/3 block text-gray-600 font-bold">
                    <div class="relative">
                        <select name="religious"
                            class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
                            id="grid-state">
                            <option value="">--Select Religious--</option>
                            <option value="hindu">Hindu</option>
                            <option value="muslim">Muslim</option>
                            <option value="sikh">Sikh</option>
                            <option value="christian">Christian</option>
                        </select>
                        <div
                            class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>
            <div class="md:flex md:items-center mb-6">
                <div class="md:w-1/3">
                    <label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4">
                        Caste
                    </label>
                </div>
                <div class="md:w-2/3 block text-gray-600 font-bold">
                    <div class="relative">
                        <select name="caste"
                            class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
                            id="grid-state">
                            <option value="">--Select Caste--</option>
                            <option value="gen">Gen</option>
                            <option value="obc">OBC</option>
                            <option value="bc">BC</option>
                            <option value="sc">SC</option>
                            <option value="st">ST</option>
                        </select>
                        <div
                            class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
                            <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                                <path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>
Activity icon

Replied to Store Or Update Enum Value

i checked,,, I get value that i set on form side but not update or store on mysql. I using Null coalescing operator for default value if user not set anything in these. i use this only for checking purpose.

Activity icon

Replied to Store Or Update Enum Value

'religious' , 'caste'

Activity icon

Started a new Conversation Store Or Update Enum Value

I working on a school management project. when i store or update enum value. Its store default value in enum field.

public function store(Request $request)
    {
        $request->validate([
            'name'              => 'required|string|max:255',
            'email'             => 'required|string|email|max:255|unique:users',
            'password'          => 'required|string|min:8',
            'parent_id'         => 'required|numeric',
            'class_id'          => 'required|numeric',
            'roll_number'       => 'required|numeric|unique:students',
            'gender'            => 'required|string',
            'phone'             => 'required|string|max:255',
            'dateofbirth'       => 'required|date',
            'current_address'   => 'required|string|max:255',
            'permanent_address' => 'required|string|max:255'
        ]);

        $user = User::create([
            'name'              => $request->name,
            'email'             => $request->email,
            'password'          => Hash::make($request->password)
        ]);

        if ($request->hasFile('profile_picture')) {
            $profile = str_slug($user->name) . '-' . $user->id . '.' . $request->profile_picture->getClientOriginalExtension();
            $request->profile_picture->move(public_path('images/profile'), $profile);
        } else {
            $profile = 'avatar.png';
        }
        $user->update([
            'profile_picture' => $profile
        ]);

        $user->student()->create([
            'parent_id'         => $request->parent_id,
            'class_id'          => $request->class_id,
            'roll_number'       => $request->roll_number,
            'gender'            => $request->gender,
            'phone'             => $request->phone,
            'religious'         => $request->religious ?? 'hindu',
            'caste'             => $request->caste ?? 'gen',
            'dateofbirth'       => $request->dateofbirth,
            'current_address'   => $request->current_address,
            'permanent_address' => $request->permanent_address
        ]);

        $user->assignRole('Student');

        return redirect()->route('student.index');
    }
public function update(Request $request, Student $student)
    {
        $request->validate([
            'name'              => 'required|string|max:255',
            'email'             => 'required|string|email|max:255|unique:users,email,' . $student->user_id,
            'parent_id'         => 'required|numeric',
            'class_id'          => 'required|numeric',
            'roll_number'       => 'required|numeric|unique:students,roll_number,' . $student->id,
            'gender'            => 'required|string',
            'phone'             => 'required|string|max:255',
            'dateofbirth'       => 'required|date',
            'current_address'   => 'required|string|max:255',
            'permanent_address' => 'required|string|max:255'
        ]);

        if ($request->hasFile('profile_picture')) {
            $profile = str_slug($student->user->name) . '-' . $student->user->id . '.' . $request->profile_picture->getClientOriginalExtension();
            $request->profile_picture->move(public_path('images/profile'), $profile);
        } else {
            $profile = $student->user->profile_picture;
        }

        $student->user()->update([
            'name'              => $request->name,
            'email'             => $request->email,
            'profile_picture'   => $profile
        ]);

        $student->update([
            'parent_id'         => $request->parent_id,
            'class_id'          => $request->class_id,
            'roll_number'       => $request->roll_number,
            'gender'            => $request->gender,
            'religious'         => $request->religious ?? 'hindu',
            'caste'             => $request->caste ?? 'gen',
            'phone'             => $request->phone,
            'dateofbirth'       => $request->dateofbirth,
            'current_address'   => $request->current_address,
            'permanent_address' => $request->permanent_address
        ]);

        return redirect()->route('student.index');
    }
Jan
10
1 month ago
Activity icon

Replied to Select A Post For One Day (Like Post Of The Day)

select one at the start of the day (any random post for one day)

Activity icon

Started a new Conversation Select A Post For One Day (Like Post Of The Day)

i Want to add Post of the day or word of the day feature to my Laravel project. Every day its change for 24 hours from my all posts including old post.

Nov
23
3 months ago
Activity icon

Replied to How To Create Unique Slug In SQL File

<?php

namespace App\Functions;

class Slug
{
    /**
     * @param $title
     * @param $model = App\Category, App\Post, App\User .............
     * @param int $id
     * @return string
     * @throws \Exception
     */
    public static function createSlug($title, $model, $id = 0)
    {
        // Normalize the title
        $slug = str_slug($title);
        // Get any that could possibly be related.
        // This cuts the queries down by doing it once.
        $allSlugs = self::getRelatedSlugs($slug, $model, $id);
        // If we haven't used it before then we are all good.
        if (!$allSlugs->contains('slug', $slug)) {
            return $slug;
        }
        // Just append numbers like a savage until we find not used.
        for ($i = 1; $i <= 50; $i++) {
            $newSlug = $slug . '-' . $i;
            if (!$allSlugs->contains('slug', $newSlug)) {
                return $newSlug;
            }
        }
        throw new \Exception('Can not create a unique slug');
    }
    protected static function getRelatedSlugs($slug, $model, $id = 0)
    {
        return $model::select('slug')->where('slug', 'like', $slug . '%')
            ->where('id', '<>', $id)
            ->get();
    }
}

i have this to create unique slug..... its too slow to done thier job. .... so i want sql function

Activity icon

Replied to How To Create A Unique Slug In SQL

can you please create any sql function to update slug field....

Activity icon

Replied to How To Create Unique Slug In SQL File

i meant a table

Activity icon

Started a new Conversation How To Create A Unique Slug In SQL

i have table name posts that have more than 10k row and i want to add a slug column that should be unique where post title is same. any solution!

If you are master in SQL please create a function....

example->

1st url = http://local.dev/this-is-post 2nd url= https//local.dev/this-is-post-2

Nov
22
3 months ago
Activity icon

Started a new Conversation How To Create Unique Slug In SQL File

i have table name posts that have more than 10k row and i want to add a slug column that should be unique where post title is same. any solution!

If you are master in SQL please create a function....

example->

1st url = http://local.dev/this-is-post 2nd url= https//local.dev/this-is-post-2

Nov
14
3 months ago
Activity icon

Started a new Conversation Sitemap Yellow Screen No Url In Wordpress

https://prashanpucho.com/sitemap_index.xml show yellow blank page. can you please tell me solution for this. i used many plugin but no fix.

Nov
12
3 months ago
Activity icon

Started a new Conversation URL & CSS Folder Same Name Problem

I have live laravel project. I'm using nginx server. I have a url -> https://fullformshindi.com/css and all you know that same url is open form public css folder. when i want to open that desire url ( https://fullformshindi.com/css for single full form) i got 403 http error. if you have any solution please write below.