Skip to content
Snippets Groups Projects
Commit 0a9c6814 authored by OlivierFrancois's avatar OlivierFrancois
Browse files

table champion, model, index (sans controller)

parent 113ea81d
Branches
No related merge requests found
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Champion extends Model
{
use HasFactory;
use SoftDeletes;
protected $fillable = ['name', 'level'];
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateChampionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('champions', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->softDeletes();
$table->string('name');
$table->integer('level');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('champions');
}
}
@extends('layouts.app')
@section('content')
<ul>
@foreach ($champions as $champion)
<li> {{ $champion->name }} de niveau {{ $champion->level }}</li>
@endforeach
</ul>
@endsection
\ No newline at end of file
<?php
use App\Models\Champion;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
......@@ -23,4 +24,8 @@ Route::get('/tryndamere', function() {
Route::get('/darius', function() {
return view('darius');
})->name('darius');
\ No newline at end of file
})->name('darius');
Route::get('/champion', function() {
return view('champion.index', ['champions' => Champion::all()]);
});
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment