By GokiSoft.com| 18:28 30/10/2021|
Học Laravel

[Examination] Bài tập ôn luyện kết thúc môn - Sử dụng Laravel + Ajax




Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Bùi Văn Mạnh [T2008A]
Bùi Văn Mạnh

2021-07-16 07:58:09



<?php

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

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email');
            $table->integer('phone');
            $table->text('note');
            $table->timestamps();
        });
    }

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



Bùi Văn Mạnh [T2008A]
Bùi Văn Mạnh

2021-07-16 07:56:44



<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Khảo sát sinh viên</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
	.form-front{
		margin-top: 50px;
		padding: 50px;
	}
</style>
<body>
<div class="container">
	<div class="form-front">
		<div class="card">
		  <div class="card-header bg-success text-light">
		  	Bảng khảo sát sinh viên
		  </div>
		  <div class="card-body">
		  	<form method="post" id="MyForm">
		  		<div class="form-group group-username">
			  		<label for="username">User Name:</label>
			  		<input required="true" type="text" name="name_username" id="username" class="form-control">
			  	</div>
			  	<div class="form-group group-fullname">
			  		<label for="email">Email:</label>
			  		<input required="true" type="email" name="name_fullname" id="email" class="form-control">
			  	</div>
			  	<div class="form-group">
			  		<label for="Phone">Phone:</label>
			  		<input type="text" name="name_birthday" id="Phone" class="form-control">
			  	</div>
			  	<div class="form-group">
			  		<label for="text">Text:</label>
			  		<input required="true" type="text" name="name_email" id="text" class="form-control">
			  	</div>
			  	<button type="submit" class="btn btn-success" id="btn_save">Send</button>
		  	</form>
		  </div>
		</div>
	</div>
</div>
</body>
</html>



Đỗ Minh Quân [T2008A]
Đỗ Minh Quân

2021-07-16 07:55:44





<!DOCTYPE html>
<html>

<head>
    <title>Survey webpage</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>

<body>
    <div class="container-fluid">
        <form method="POST" action="process_form.php">
            <div class="form-group">
                <label for="name">Name:</label>
                <input type="text" class="form-control" id="name" placeholder="nhap du lieu" name="name">
            </div>
            <div class="form-group">
                <label for="email">Email:</label>
                <input type="email" class="form-control" id="email" placeholder="nhap du lieu" name="email">
            </div>
            <div class="form-group">
                <label for="telephone">Telephone:</label>
                <input type="text" class="form-control" id="telephone" placeholder="nhap du lieu" name="telephone">
            </div>
            <div class="form-group">
                <label for="feedback">Feedback:</label>
                <input type="text" class="form-control" id="telephone" placeholder="nhap du lieu" name="feedback">
            </div>
            <button class="btn btn-success">Submit</button>
        </form>
    </div>
</body>
</html>



Nguyễn Hữu Hiếu [T2008A]
Nguyễn Hữu Hiếu

2021-07-16 07:53:36



<!DOCTYPE html>
<html>
<head>
	<title>Survey Form</title>
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

	<!-- jQuery library -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

	<!-- Popper JS -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

	<!-- Latest compiled JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="panel panel-primary">
			<div class="panel-heading">
				<h2 class="text-center">Survey Form</h2>
			</div>
			<div class="panel-body">
				<div class="form-group">
				  <label for="name">Name:</label>
				  <input required="true" type="text" class="form-control" id="name">
				</div>
				<div class="form-group">
				  <label for="email">Email:</label>
				  <input required="true" type="email" class="form-control" id="email">
				</div>
				<div class="form-group">
				  <label for="birthday">Telephone:</label>
				  <input type="phone" class="form-control" id="phone">
				</div>
				<div class="form-group">
				  <label for="pwd">Feedback:</label>
				  <input required="true" type="feebback" class="form-control" id="feebback">
				</div>
				<button class="btn btn-success">SEND SURVEY</button>
			</div>
		</div>
	</div>
</body>
</html>



<?php

namespace App\Http\Controllers\Student;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;


class StudentController extends Controller {
	
	public function save(Request $request) {
		
		$name    	= $request->name;
		$email     	= $request->email;
		$phone 		= $request->phone;
		$feedback 	= $request->feedback;

		

		
		DB::table('students')->insert([
				'name'       => $name,
				'email'   	=> $email,
				'phone'   	=> $phone,
				'feedback'   	=> $feedback,


			]);

		return redirect()->route('student_index');
	}
}



<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
| SEO
 */


Route::group(['prefix' => '/student'],
function () {
		Route::get('/index', [App\Http\Controllers\Student\StudentController::class , 'index'])->name('student_index');

		
	});



<?php

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

class CreateStudentsTable extends Migration {
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up() {
		Schema::create('students', function (Blueprint $table) {
				$table->string('name', 50);
				$table->string('email', 50);
				$table->string('telephone', 25);
				$table->string('feedback', 500);
				
			});
	}

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



Đỗ Mạc Nam [T2008A]
Đỗ Mạc Nam

2021-07-16 07:52:48



<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class KhaoSat extends Model
{
    protected $table = 'categories' ;
    protected $key = 'id' ;
    protected $fillable = [
        'name',
        'email',
        'phone',
        'note',
    ];
}



Đỗ Mạc Nam [T2008A]
Đỗ Mạc Nam

2021-07-16 07:52:26



<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class KhaoSat extends Controller
{
    public function index()
    {
        return view('khaosat');
    }
}



Đỗ Mạc Nam [T2008A]
Đỗ Mạc Nam

2021-07-16 07:51:12



<?php

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

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email');
            $table->integer('phone');
            $table->text('note');
            $table->timestamps();
        });
    }

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



Đỗ Mạc Nam [T2008A]
Đỗ Mạc Nam

2021-07-16 07:50:23



<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Khảo sát sinh viên</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
	.form-front{
		margin-top: 50px;
		padding: 50px;
	}
</style>
<body>
<div class="container">
	<div class="form-front">
		<div class="card">
		  <div class="card-header bg-success text-light">
		  	Bảng khảo sát sinh viên
		  </div>
		  <div class="card-body">
		  	<form method="post" id="MyForm">
		  		<div class="form-group group-username">
			  		<label for="username">User Name:</label>
			  		<input required="true" type="text" name="name_username" id="username" class="form-control">
			  	</div>
			  	<div class="form-group group-fullname">
			  		<label for="email">Email:</label>
			  		<input required="true" type="email" name="name_fullname" id="email" class="form-control">
			  	</div>
			  	<div class="form-group">
			  		<label for="Phone">Phone:</label>
			  		<input type="text" name="name_birthday" id="Phone" class="form-control">
			  	</div>
			  	<div class="form-group">
			  		<label for="text">Text:</label>
			  		<input required="true" type="text" name="name_email" id="text" class="form-control">
			  	</div>
			  	<button type="submit" class="btn btn-success" id="btn_save">Send</button>
		  	</form>
		  </div>
		</div>
	</div>
</div>
</body>
</html>



Trần Thị Khánh Huyền [T2008A]
Trần Thị Khánh Huyền

2021-07-16 07:48:16


#create_survey_table


<?php

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

class CreateLuatgiaothongTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('luatgiaothong', function (Blueprint $table) {
            $table->string('Student Name', 100);
            $table->string('Student Email', 500);
            $table->integer('Student Telephone');
            $table->string('Feedback', 1000);
           
        });
    }

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



Trần Thị Khánh Huyền [T2008A]
Trần Thị Khánh Huyền

2021-07-16 07:47:53


#surveyController.php


<?php

namespace App\Http\Controllers\luatgiaothong;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;
class luatgiaothongController extends Controller
{
    function showList(Request $request){
          
        if (isset($request->title)) {
            $list= DB::table('luatgiaothong')
            ->where('title','like','%'.$request->title.'%')
            ->paginate(10);       
        }else{
            $list= DB::table('luatgiaothong')->paginate(10);

        }    
        return view('luatgiaothong.list')->with([
            'list' => $list,
            'index'=>1
        
        ]);
    }
    function showDetail(Request $request){
        if (isset($request->id)) {
            # code...
            $detail = DB::table('luatgiaothong')
            ->where('id',$request->id)
            ->first();
        }
        return view('luatgiaothong.detail')->with([
            'detail' => $detail
        
        ]);
          
    }
}<font color="#000000" face="Arial, sans-serif"><span style="font-size: 15px; white-space: normal;">
</span></font>



Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó