Reset
Employee Registration with File Upload and Database Storage
Program Info
Program Code
×

Employee Registration with File Upload and Database Storage

This code registers a new employee. It validates the employee details, uploads the employee file, creates a unique employee ID, saves the employee information in the database, and sets the employee status as active.

Footer

×

Employee Registration with File Upload and Database Storage

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Employee;


class Employee_Controller extends Controller
{
    public function index()
    {
        return view('employee');
    }

    public function register(Request $request)
    {
        //print_r($request->all());
        $filename = $request->file('file')->getClientOriginalName();
        //$request->file()->store('uploads');
        $request->file('file')->storeAs('public/uploads',$filename);
        $request->validate([
             'name' => 'required',
             'email' => 'required|email',
             'address' => 'required',
             'doj' => 'required',
             'gender' => 'required',
             'file' => 'required',


        ]);

        $employee = new Employee;
        $employee->emp_id = mt_rand(11111,99999);
        $employee->name = $request['name'];
        $employee->email = $request['email'];
        $employee->address = $request['address'];
        $employee->doj = $request['doj'];
        $employee->gender = $request['gender'];
        $employee->image = $filename;
        $employee->status = 1;
        $employee->save();
       
    }
}

Footer

Exclude Employee by ID
Program Info
Program Code
×

Exclude Employee by ID

This query fetches all employees except the employee whose id is 50000.

Footer

×

Exclude Employee by ID

<?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')->where('id','<>',50000)->get();
        echo "<pre>";
        print_r($data->toArray());

    }
}

Footer

Fetch 10 Employees After Skipping the First 5
Program Info
Program Code
×

Fetch 10 Employees After Skipping the First 5

This query skips the first 5 employee records and fetches the next 10 records from the employee table. The result is then converted into an array and displayed.

Footer

×

Fetch 10 Employees After Skipping the First 5

<?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')->offset(5)->limit(10)->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Fetch All Employee Names Using Laravel Pluck
Program Info
Program Code
×

Fetch All Employee Names Using Laravel Pluck

This query gets all employee names from the employee table using Laravel's pluck() method and displays them as an array.

Footer

×

Fetch All Employee Names Using Laravel Pluck

<?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')->pluck('name');
         echo "<pre>";
         print_r($data->toArray());


    }
}

Footer

Fetch All Employee Records
Program Info
Program Code
×

Fetch All Employee Records

Retrieves all records from the employee table and displays them in a readable array format.

Footer

×

Fetch All Employee Records

<?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')->get();
        echo "<pre>";
        print_r($data->toArray());


    }
}

Footer

Fetch Employees by Address
Program Info
Program Code
×

Fetch Employees by Address

Retrieves all employees from the employee table whose address is india and displays the results as an array.

Footer

×

Fetch Employees by Address

<?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')->where('address','india')->get();
        echo "<pre>";
        print_r($data->toArray());


    }
}

Footer

Fetch Employees by Address and Gender
Program Info
Program Code
×

Fetch Employees by Address and Gender

Fetches all employees from the employee table whose address is "india" and gender is "O". Displays the matching records as an array.

Footer

×

Fetch Employees by Address and Gender

<?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')->where(['address'=>'india','gender'=>'O'])->get();
        echo "<pre>";
        print_r($data->toArray());


    }
}

Footer

Fetch Employees by Multiple IDs
Program Info
Program Code
×

Fetch Employees by Multiple IDs

This query fetches employees whose IDs are 1, 5, or 10 from the employee table.

Footer

×

Fetch Employees by Multiple IDs

<?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')->whereIn('id',[1,5,10])->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Fetch Employees from America or India
Program Info
Program Code
×

Fetch Employees from America or India

This query gets employees whose address is either exactly "America" or contains the word "India".

Footer

×

Fetch Employees from America or India

<?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')->where('address','America')->orwhere('address','like','%india%')->get();
        echo "<pre>";
        print_r($data->toArray());
    }
}

Footer

Fetch Employees from India with Gender O
Program Info
Program Code
×

Fetch Employees from India with Gender O

This query retrieves all employees from the employee table whose address is india and gender is O. It displays the results as an array.

Footer

×

Fetch Employees from India with Gender O

<?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')->where('address','india')->where('gender','O')->get();
        echo "<pre>";
        print_r($data->toArray());


    }
}

Footer

Showing page  3  of  8  (Total  77 records)
« Prev  1  2  3  4  5 ... 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