By GokiSoft.com|
18:38 21/05/2022|
Học PHP
[Examination] Thi kết thúc khóa học PHP - Đề 1
Đề Thi Môn PHP
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Đỗ Mạc Nam [T2008A]](https://www.gravatar.com/avatar/71dd707204cf6115a4fe17bbdee2b5fa.jpg?s=80&d=mm&r=g)
Đỗ Mạc Nam
2021-06-30 09:04:47
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class LibrarySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($i=1; $i <= 10; $i++) {
DB::table('library')->insert([
'authorid' => $i,
'title' => 'Quyen sach ' . $i,
'ISBN' => '123' . $i,
'pub_year' => '200'.$i,
'available' => $i + 20
]);
}
}
}
![Đỗ Mạc Nam [T2008A]](https://www.gravatar.com/avatar/71dd707204cf6115a4fe17bbdee2b5fa.jpg?s=80&d=mm&r=g)
Đỗ Mạc Nam
2021-06-30 09:04:24
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLibraryTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('library', function (Blueprint $table) {
$table->id('bookid');
$table->integer('authorid');
$table->string('title');
$table->string('ISBN');
$table->integer('pub_year');
$table->integer('available');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('library');
}
}
![Đỗ Mạc Nam [T2008A]](https://www.gravatar.com/avatar/71dd707204cf6115a4fe17bbdee2b5fa.jpg?s=80&d=mm&r=g)
Đỗ Mạc Nam
2021-06-30 08:56:57
Thay dep trai :v
![Nguyễn Tiến Đạt [T2008A]](https://www.gravatar.com/avatar/b5819cd0adc95c727c7ad0c2bcf6098b.jpg?s=80&d=mm&r=g)
Nguyễn Tiến Đạt
2021-06-30 08:49:21
#2021_06_30_080815_create_library_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLibraryTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('library', function (Blueprint $table) {
$table->id('bookid');
$table->integer('authorid')->default(0);
$table->string('title',55);
$table->string('ISBN',25);
$table->smallInteger('pub_year')->default(0);
$table->tinyInteger('available');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('library');
}
}
#LibrarySeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class LibrarySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($i=1; $i <= 5; $i++) {
DB::table('library')->insert([
'authorid' => $i,
'title' => 'Quyen sach so ' . $i,
'ISBN' => '123-456-78-' . $i,
'pub_year' => '200'.$i,
'available' => $i + 10
]);
}
}
}
#data.php
<?php
use Illuminate\Support\Facades\Route;
/*
Route::group([],function(){
Route::get('/helloworld',[\App\Http\Controllers\Data\DataController::class,"showHelloWorld"]);
Route::get('/gia-tri-x/{x}/gia-tri-y/{y}',function($x,$y){
$s = $x+$y;
return $s;
});
});
Route::group(['prefix' => '/homework'],function(){
Route::get('/helloworld',function(){
return '<h1>Hello Nguyen Tien Dat</h1>';
});
// Route::get('/PTB1/a/{a}/b/{b}',function($a,$b){
// if($a == 0){
// if($b == 0) return 'PTVSN';
// else return 'PTVN';
// }
// return 'x = '. -$b/$a;
// });
Route::get('/PTB1/a/{a}/b/{b}',[\App\Http\Controllers\Data\DataController::class,"PTB1"]);
Route::get('/student/display',[\App\Http\Controllers\Lesson01\StudentController::class,"showStudent"]);
Route::get('/ptb2/{a}x2+{b}x+{c}',[\App\Http\Controllers\Data\DataController::class,"PTB2"]);
});
Route::group(['prefix' => '/book'],function(){
Route::get('/bookList',[\App\Http\Controllers\Book\BookController::class,"showBook"]);
});
Route::group(['prefix' => '/traffic'],function(){
Route::get('/index',[\App\Http\Controllers\Traffic\TrafficController::class,"showTraffic"]) -> name('traffic_list');
});
*/
Route::get('/library/index',[\App\Http\Controllers\Library\LibraryController::class,"showBook"]) -> name('book_list');
#LibraryController.php
<?php
namespace App\Http\Controllers\Library;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class LibraryController extends Controller
{
public function showBook(Request $request)
{
$search = $request->search;
$bookList = DB::table('library');
if(isset($search) && $search > 0){
$bookList = $bookList->where('library.title','like','%'.$search.'%');
}
$bookList = $bookList->get();
return view('library.index')->with([
'bookList' => $bookList,
'index' => 1
]);
}
}
#index.blade.php
<!doctype html>
<html lang="en">
<head>
<title>Book List</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="{{ asset('css/library.css') }}">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Book List</h1>
<form method="get">
<div class="form-group">
<input type="text" class="form-control" name="search" placeholder="Searching for title...">
</div>
</form>
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Title</th>
<th>ISBN</th>
<th>Publish Year</th>
<th>Available</th>
</tr>
</thead>
<tbody>
@foreach ($bookList as $book)
<tr>
<td>{{$index++}}</td>
<td>{{$book -> title}}</td>
<td>{{$book -> ISBN}}</td>
<td>{{$book -> pub_year}}</td>
<td>{{$book -> available}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
#library.css
body{
background-color: cornflowerblue !important;
}
.table-bordered td, .table-bordered th{
border:2px solid black !important;
}
h1{
text-align: center;
color: green;
}
input{
width: 200px !important;
}
th{
color: yellow;
}
td{
color: purple;
}
![Nguyễn Tiến Đạt [T2008A]](https://www.gravatar.com/avatar/b5819cd0adc95c727c7ad0c2bcf6098b.jpg?s=80&d=mm&r=g)
Nguyễn Tiến Đạt
2021-06-30 08:46:37
Test
![hainguyen [T2008A]](https://www.gravatar.com/avatar/32855ce6db55d60134d830aee06b41e5.jpg?s=80&d=mm&r=g)
hainguyen
2021-06-30 08:16:36
kết quả thi lý thuyết
![Nguyễn đình quân [T2008A]](https://www.gravatar.com/avatar/46aca6afcfe99fdb28357afb847d8a0c.jpg?s=80&d=mm&r=g)
Nguyễn đình quân
2021-06-30 08:04:48
#Ảnh chụp màn hình (48).png
https://res.cloudinary.com/wegoup/image/upload/v1625040284/zjontbixujgd1etqpajh.png
![Nguyễn Tiến Đạt [T2008A]](https://www.gravatar.com/avatar/b5819cd0adc95c727c7ad0c2bcf6098b.jpg?s=80&d=mm&r=g)
Nguyễn Tiến Đạt
2021-06-30 08:01:31
Lý thuyết
![nguyễn Sử [T2008A]](https://www.gravatar.com/avatar/47487be2776ac2ec915b0936ef7ab5ae.jpg?s=80&d=mm&r=g)
nguyễn Sử
2021-06-30 07:59:56
#209462408_3013687408920542_3023476914960886619_n.png
https://res.cloudinary.com/wegoup/image/upload/v1625039946/pgo1ywkqix3i7t7ecqkf.png
![Trần Thị Khánh Huyền [T2008A]](https://www.gravatar.com/avatar/554e115833778e4294a01aebe228f3d6.jpg?s=80&d=mm&r=g)
Trần Thị Khánh Huyền
2021-06-30 07:59:24
thi lý thuyết