Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
public function scopeIncomplete($query) {
return $query->where('completed', 0);
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksTable extends Migration
{
/**
* Run the migrations.
<?php
Route::get('/', function () {
return view('welcome');
});
//add view
Route::get('/tasks/{task}', function ($id) {
$task = App\Task::find($id);
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
</head>
<body>
<ul>
@foreach ($tasks as $task)
<li>
<a href= "../public/tasks/{{ $task->id }}">
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
</head>
<body>
<h1>{{ $task->body }}</h1>
</body>
</html>
<?php
/*
|--------------------------------------------------------------------------
| 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!
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
</head>
<body>
<ul>
@foreach ($tasks as $task)
<li>{{ $task->body }}</li>
@endforeach
<?php
/*
|--------------------------------------------------------------------------
| 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!
<?php
/*
|--------------------------------------------------------------------------
| 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!
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksTable extends Migration
{
/**
* Run the migrations.