title: Can't get data from database - Laravel
body: <p>I have a very simple and short code more or less directly from a course but it doesnt work. I get an error nobody seemingly had before because I can't find a single webpage where my exact error is mentioned.</p>
  
  <p>I'm just trying to get data from my (sql) database in a controller with Laravel. Controller:</p>
  
  <pre><code> &lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Joke as Joke;
  
  
  class ContentsController extends Controller
  {
  
  public function __construct( Joke $joke )
  {
      $this-&gt;joke = $joke;
  }
  //
  public function index()
  {
      $data = [];
      $data = ['jokes'] = $this-&gt;joke-&gt;all();
  
  
      return view('index', $data);
  }
  }
  </code></pre>
  
  <p>DB migration:
     
  
  <pre><code>use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateJokesTable extends Migration
  {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
      Schema::create('jokes', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;string('joke');
          $table-&gt;integer('upvotes');
          $table-&gt;integer('downvotes');
          $table-&gt;integer('user_id')-&gt;unsigned();
          $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');
      });
  }
  
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
      Schema::dropIfExists('jokes');
  }
  }
  </code></pre>
  
  <p>When I try to run it I get this error: "Assignments can only happen to writable values" and its exactly on the line with 
  <code>$data = ['jokes'] = $this-&gt;joke-&gt;all();</code></p>
  
  <p>I'm totally lost. </p>