make your migration with type
php artisan make:migration create_tasks_table --create=tasks
than change like this :
public function up()
{
Schema::create('tasks', function (Blueprint $table) {
$table->increments('id');
$table->text('body');
$table->timestamps();
});
}
php artisan make:migration create_tasks_table --create=tasks
than change like this :
public function up()
{
Schema::create('tasks', function (Blueprint $table) {
$table->increments('id');
$table->text('body');
$table->timestamps();
});
}
send your migration in your database type
php artisan migration
dont refres your migration coz you will delete a table you created.
than change your folder in routes/web.php make a code like below:
Route::get('/tasks', function () {
$tasks = DB::table('tasks')->latest()->get();
return view('tasks.index',compact('tasks'));
});
Route::get('/tasks/{task}', function ($id) {
$task = DB::table('tasks')->find($id);
return view('tasks.show',compact('task'));
});
First of the Route is get all database
and second to get id in all database
after all make a folder tasks in view
resources/views/tasks than input php for example
index.blade.php
<!DOCTYPE html>
<html>
<head>
<title>tes</title>
</head>
<body>
<ul>
<?php foreach ($tasks as $task ) :?>
<a href="/tasks/{{$task->id}}">
<li><?=$task->body;?></li>
</a>
<?php endforeach; ?>
</ul>
</body>
</html>
in here for get id and repeat all database in accordance of all database .
you can remember it with use the word foreach that for repeat.
and make show.blade.php
<!DOCTYPE html>
<html>
<head>
<title>blade show</title>
</head>
<body>
<h1>{{ $task->body}}</h1>
</body>
</html>
in here you get all database but just accordance in id .