HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/owlcrm/app/first-project/app/Http/Controllers/librariesController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Psy\Command\HistoryCommand;

class librariesController extends Controller
{
    public function form()
    {
        $libraries = DB::table('libraries')->get();
        return view('library.form');
    }

    public function show()
    {
        $libraries = DB::table('libraries')->get();
        return view('library.show', ['data' => $libraries]);
    }



    public function save(request $req)
    {
        $req->validate([
            'username' => 'required',
            'useremail' => 'required|email',
            'userage' => 'required|numeric|min:18',
            'usercity' => 'required'
        ]);



        //   return  dd($req->all());
        $library = DB::table('libraries')
            ->insert([
                'name' => $req->username,
                'email' => $req->useremail,
                'age' => $req->userage,
                'city' => $req->usercity,
                'phone-no' => 56566,
            ]);

        if ($library) {
            return redirect()->route('library.show')->with('message', "data inserted successfully...");
        } else {
            echo "<h1>error...</h1>";
        }
    }
}







/*{

$libraries = DB:: table('libraries')
                        ->join ('id','libraries.id','=','students.id')
                        ->get();
return $libraries;




    public function showlibrary($all ="")
    {
        if($all != ''){
            $libraries = DB::table('libraries')->get();
        }else{

            $libraries = DB::table('libraries')
            ->paginate(3)
            ->appends(['sort' => 'votes']);
        }
        return view('alllibraries', ['data' => $libraries,'all'=> $all]);
    }

    public function singlelibrary(string $id)
    {
        $library = DB::table('libraries')->where('id', $id)->get();
        return view('library', ['data' => $library]);
    }


    public function addlibrary() {
        $library = DB::table('libraries')
                  ->insert([
                    [
                        'id' => '15',
                        'book' => 'drawing',
                        'created_at' => '2023-12-21 18:09:46',
                        'updated_at' => '2023-12-21 18:09:46'
                    ],
                    [
                        'id' => '16',
                        'book' => 'litracuter',
                        'created_at' => '2023-12-21 18:09:46',
                        'updated_at' => '2023-12-21 18:09:46'
                    ],
                    [
                        'id' => '17',
                        'book' => 'grammer',
                        'created_at' => '2023-12-21 18:09:46',
                        'updated_at' => '2023-12-21 18:09:46'
                    ],
                    [
                        'id' => '18',
                        'book' => 'story book',
                        'created_at' => '2023-12-21 18:09:46',
                        'updated_at' => '2023-12-21 18:09:46'
                    ],
                    [
                        'id' => '19',
                        'book' => 'sketch book',
                        'created_at' => '2023-12-21 18:09:46',
                        'updated_at' => '2023-12-21 18:09:46'
                    ],
                    [
                        'id' => '20',
                        'book' => 'rhyme book',
                        'created_at' => 'c2023-12-21 18:09:46',
                        'updated_at' => '2023-12-21 18:09:46'
                    ]
                  ]);


            if($library)
            {
               echo "<h1>data inserted successfully...</h1>";
            }
    }


   public function updatepage(string $id) {
            //$library = DB::table('libraries')->where('id',$id)->get();
            $library = DB::table('libraries')->find($id);
            return view('updatepage',['data' =>$library]);
   }



    public function updatelibrary(request $req, $id)
    {
        $library = DB::table('libraries')
            ->where('id', $id)
            ->update([
                       'book' => $req->book,
                       'created_at' => new \DateTime(),
                       'updated_at' => new \DateTime(),
                       'email' => $req->email,
                       'phone' =>$req->phone,
                       'city' =>$req->city,
            ]);
            if($library)
            {
               echo "<h1>data inserted successfully...</h1>";
            }
            else
            {
                echo"error...";
            }
        }

    public function deletelibrary(string $id)
    {
        $library = DB::table('libraries')
            ->where('id', $id)
            ->delete();


        if ($library) {
            return redirect()->route('show.library');
        }
    }


    public function addlibrary(Request $req) {
    //   return  dd($req->all());
        $library = DB::table('libraries')
            ->insert([
                'book' => $req->book,
                'created_at' => new \DateTime(),
                'updated_at' => new \DateTime(),
                'email' => $req->email,
                'phone' =>$req->phone,
                'city' =>$req->city,
            ]);
        if ($library) {
            return redirect()->route('show.library')->with('message',"data updated successfully...");
        }
        else
        {
            echo "<h1>error...</h1>";
        }
    }

    //public function create() {
       // return dd(12);
    }*/