Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Feature::create(['name' => '4-Wheel Disc Brakes']);
     Feature::create(['name' => 'ABS Brakes']);
     Feature::create(['name' => '9 Speakers']);
     Feature::create(['name' => 'AM/FM Radio: Siriusxm']);
     Feature::create(['name' => 'Mp3 Decoder']);
     Feature::create(['name' => 'Security System']);
 }
Exemplo n.º 3
0
<?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');
});
Exemplo n.º 4
0
Arquivo: Car.php Projeto: Reta110/cars
 public function saveFeatures(array $features)
 {
     $features = Feature::whereIn('id', $features)->orWhereIn('name', $features)->get();
     $this->features()->sync($features);
 }