Reset
Count Total Employees
Program Info
Program Code
×

Count Total Employees

This query counts the total number of records in the employee table and returns the count.

Footer

×

Count Total Employees

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
    public function index()
    {
        $data = DB::table('employee')->count();
        echo "<pre>";
        print_r($data);
    }
}

Footer

Create 100 Fake Employee Records Using Laravel Seeder
Program Info
Program Code
×

Create 100 Fake Employee Records Using Laravel Seeder

This seeder creates 100 employee records with random ID, name, email, address, date of joining, gender, and status using Faker, then saves them to the database.

Footer

×

Create 100 Fake Employee Records Using Laravel Seeder

<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Employee;
use Faker\Factory as Faker;

class EmployeeSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $faker = Faker::create();
        for($i=0;$i<100;$i++){
            $employee = new Employee;
            $employee->emp_id = mt_rand(11111,99999);
            $employee->name = $faker->name;
            $employee->email = $faker->email;
            $employee->address = $faker->address;
            $employee->doj = $faker->date;
            $employee->gender = 'M';
            $employee->status = 1;
            $employee->save();
        }
       
    }
}

Footer

Create Controller for Profile
Program Info
Program Code
×

Create Controller for Profile

We creating controller that allow us to perform all crud operation on account or profile.

Footer

×

Create Controller for Profile

<?php

namespace App\Http\Controllers;

use App\Http\Requests\ProfileUpdateRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;

class ProfileController extends Controller
{
    /**
     * Display the user's profile form.
     */
    public function edit(Request $request): View
    {
        return view('profile.edit', [
            'user' => $request->user(),
        ]);
    }

    /**
     * Update the user's profile information.
     */
    public function update(ProfileUpdateRequest $request): RedirectResponse
    {
        $request->user()->fill($request->validated());

        if ($request->user()->isDirty('email')) {
            $request->user()->email_verified_at = null;
        }

        $request->user()->save();

        return Redirect::route('profile.edit')->with('status', 'profile-updated');
    }

    /**
     * Delete the user's account.
     */
    public function destroy(Request $request): RedirectResponse
    {
        $request->validateWithBag('userDeletion', [
            'password' => ['required', 'current_password'],
        ]);

        $user = $request->user();

        Auth::logout();

        $user->delete();

        $request->session()->invalidate();
        $request->session()->regenerateToken();

        return Redirect::to('/');
    }
}

Footer

Create Controller for Return String
Program Info
Program Code
×

Create Controller for Return String

We creating a controller that will return string data.

Footer

×

Create Controller for Return String

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class Home_Controller extends Controller
{
    public function index($value='')
    {
        return "Wellcome to Home Controller <br>Value is :".$value;
    }

    public function show($value='')
    {
        return "Wellcome to Home Controller <br>Value is :".$value;
    }

    public function edit($value='')
    {
        return "Wellcome to Home Controller <br>Value is :".$value;
    }
}

Footer

Create Controller for View Load
Program Info
Program Code
×

Create Controller for View Load

We creating a controller that will load view with data

Footer

×

Create Controller for View Load

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class View_Load_Controller extends Controller
{
    public function index($value='')
    {
        return view('load_view_page')->with(['value'=>$value]);
    }
}

Footer

Create Employee Table Using Laravel Migration
Program Info
Program Code
×

Create Employee Table Using Laravel Migration

This migration creates an employee table with employee ID, email, address, joining date, status, and timestamps. The down() method removes the table when the migration is rolled back.

Footer

×

Create Employee Table Using Laravel Migration

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('employee', function (Blueprint $table) {
            $table->id();
            $table->string('emp_id',65);
            $table->string('email',65);
            $table->text('address',150)->nullable();
            $table->date('doj');
            $table->boolean('status')->default(1);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('employee');
    }
};

Footer

Create Failed Jobs Table Migration
Program Info
Program Code
×

Create Failed Jobs Table Migration

This migration creates a failed_jobs table to store information about Laravel jobs that fail during execution.

Footer

×

Create Failed Jobs Table Migration

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('failed_jobs', function (Blueprint $table) {
            $table->id();
            $table->string('uuid')->unique();
            $table->text('connection');
            $table->text('queue');
            $table->longText('payload');
            $table->longText('exception');
            $table->timestamp('failed_at')->useCurrent();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('failed_jobs');
    }
};

Footer

Create Resource Controller
Program Info
Program Code
×

Create Resource Controller

We creating a resource controller that will do create some important methods automatically.

Footer

×

Create Resource Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class Resource_Controller extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     */
    public function show(string $id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(string $id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, string $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(string $id)
    {
        //
    }
}

Footer

Create Users Table with Laravel Migration
Program Info
Program Code
×

Create Users Table with Laravel Migration

This migration creates a users table with fields for user name, email, password, email verification, remember token, and timestamps. It also removes the users table when the migration is rolled back.

Footer

×

Create Users Table with Laravel Migration

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};

Footer

Delete an Employee Record by Employee ID
Program Info
Program Code
×

Delete an Employee Record by Employee ID

Deletes the employee record from the employee table where the ID is 39418.

Footer

×

Delete an Employee Record by Employee ID

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Query_Controller extends Controller
{
    public function index()
    {
        DB::table('employee')->where('id',39418)->delete();    
    }
}

Footer

Showing page  2  of  8  (Total  77 records)
« Prev  1  2  3  4 ... 8  Next »
×
Name : Krishna Verma    |    Father's Name : Mr. Satish Kumar    |    Email ID : krishnaverma28081997@gmail.com    |    Religion : Hindu    |    Address : Dayampur, kanker khera, Meerut Cantt (250001), UP    |    Date of Birth : 28 August 1997    |    Marital Status : Non-Married    |    Place of Birth : Dayampur Kanker Khera Meerut Cantt.    |    Gender : Male    |    Age : 28    |    Contact : 9520335394    |    Father's Occupation : Sports man    |    Mother's Name : Smt. Kuntesh Devi    |    Mother's Occupation : Homemaker    |    Number of Brothers : 1    |    Number of Sisters : 1    |    Current Residence : Dayampur kanker khera meerut cantt    |    Family Type : Nuclear Family    |    Family Name : verma    |    Height : 5' 6"    |    Weight : 70 kg    |    Complexion : Fair    |    Body Type : Athletic    |    Hair Color : Black    |    Health Status : Good    |    Any Physical Disability : No    |    Highest Qualification : B.Tech (CSE)    |    Master Skill : PHP Laravel    |    Total Projects : 40 +    |    Total Skills : 25 +    |    Languages Known : Hindi and English    |    Website : krishnaportfolio.in    |    Siblings : 3    |    Nationality : Indian    |    Total Experience : 5 Years    |    LinkedIn : https://www.linkedin.com/in/krishna-verma-840b71356/    |    Total Programs : 10000    |    Total Projects : 40    |    Total Skills : 25    |    Total Experience : 5    |    Total DSA Problems : 200    |    Total Served Companies : 2    |    Leetcode : https://leetcode.com/u/krishnavermadeveloper/    |    Naukri : https://www.naukri.com/mnjuser/profile?id=&altresid