/** * Fungsi untuk menyimpan testimoni product * @param Request $request [description] * @return [type] [description] */ public function store(Request $request) { $this->validate($request, ['point_speed' => 'required', 'point_quality' => 'required', 'point_package' => 'required', 'product_id' => 'required|exists:products,id']); $testimony = $request->only('subject', 'testimonial', 'point_speed', 'point_quality', 'point_package', 'product_id'); $testimony = Testimonial::create($testimony); if ($testimony) { return ['status' => 'success', 'message' => 'Testimoni berasil disimpan.', 'testimony' => $testimony]; } else { return ['status' => 'failed', 'message' => 'Testimoni gagal disimpan.', 'testimony' => null]; } }
/** * Run the migrations. * * @return void */ public function up() { // Schema::create('testimonials', function (Blueprint $table) { $table->increments('id'); $table->string('author'); $table->string('title')->nullable(); $table->string('company'); $table->text('quote'); $table->string('photo')->nullable(); $table->timestamps(); $table->timestamp('published')->nullable(); $table->softDeletes(); }); Testimonial::create(['author' => 'Dan Hughes', 'title' => 'CEO', 'company' => 'PT Northwest LLC', 'quote' => 'Not only good speakers, but excellent scheduling to allow for good opportunities for networking.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]); Testimonial::create(['author' => 'Jon Turino', 'company' => 'COUNTRY Financial', 'quote' => 'The diverse program for this event has a little something for everyone.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]); Testimonial::create(['author' => 'Cynthia Wetlesen', 'title' => 'Owner', 'company' => 'Affordable Insurance Strategies', 'quote' => 'The speakers and topics were pertinent and beneficial.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]); Testimonial::create(['author' => 'Sam Darcy', 'title' => 'CEO', 'company' => 'Astoria Pointe', 'quote' => 'Professional delivery of relevant topics. Looking forward to the next event.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]); }