public function test_filter_features() { Feature::create(['name' => 'Feature 1']); Feature::create(['name' => 'Feature 2']); Feature::addNewFeatures(['Feature 2', 'Feature 3', ' Feature 3 ', 'Feature 4', 'Feature 4']); $this->assertSame(['Feature 1', 'Feature 2', 'Feature 3', 'Feature 4'], Feature::lists('name')->toArray()); }
<?php use Cars\Models\Car; use Cars\Models\Feature; Route::get('features', function () { $car = Car::first(); $features = Feature::orderBy('name', 'ASC')->lists('name', 'id')->toArray(); return view('components/features', compact('features', 'car')); }); Route::post('features', function () { $features = Request::get('features'); Feature::addNewFeatures($features); $car = Car::first(); $car->saveFeatures($features); return redirect()->to('features'); });