/** * Store a newly created resource in storage. * * @return Response */ public function store() { $class = new Testimonial(); $class->fill(Request::all()); $class->location()->associate(Location::current()); $class->save(); return $class; }
public function run() { DB::table('testimonials')->delete(); $testimonials = [["quote" => "Great job on the steel roofing order. I've saved nearly as much on electric bills as the materials cost. My electric bill was \$235 before, the next month it was \$137. Looks great! Thanks!", "author" => "L. Adams"], ["quote" => "This is a sample quote to test the swapping out of different quotes using JavaScript", "author" => "Steven Barnett"], ["quote" => "Reed's Metals is coooooooooooool", "author" => "Stephanie Barnett"]]; $locations = Location::all(); foreach ($testimonials as $testimonial) { foreach ($locations as $location) { $newTestimonial = new Testimonial(['quote' => $testimonial['quote'], 'author' => $testimonial['author']]); $newTestimonial->location()->associate($location); $newTestimonial->save(); } } }