Jelajahi Sumber

[+] add posts skeleton

Artem Petrov 5 tahun lalu
induk
melakukan
ebf30862c8

+ 26 - 0
app/Http/Controllers/PostsController.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: artem
+ * Date: 21.09.18
+ * Time: 21:00
+ */
+
+namespace App\Http\Controllers;
+
+use App\Post;
+
+class PostsController extends Controller
+{
+    /**
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    public function index()
+    {
+        $posts = Post::all();
+
+        return view('posts.index', [
+            'index' => $posts,
+        ]);
+    }
+}

+ 15 - 0
app/Post.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: artem
+ * Date: 21.09.18
+ * Time: 20:54
+ */
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Post extends Model
+{
+}

+ 36 - 0
database/migrations/2018_09_21_175620_create_posts_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePostsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('posts', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('title');
+            $table->text('description');
+            $table->integer('user_id')->unsigned();
+            $table->timestamps();
+
+            $table->foreign('user_id')->references('id')->on('users');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('posts');
+    }
+}

+ 0 - 0
resources/views/posts/index.blade.php