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(); } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $class = Testimonial::find($id); if ($class->delete()) { return Response::json('success', 200); } else { return Response::json('error', 400); } }