Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Reverted occurrencecontroller back to previous way. Changed occurs_at…
Browse files Browse the repository at this point in the history
… from timestamp to datetime.
  • Loading branch information
Mario Basic committed Jul 31, 2016
1 parent 7a5b8cf commit c98c219
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/Http/Controllers/Api/OccurrenceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@

class OccurrenceController extends Controller
{
public function toggleOffer($id, Request $request)
public function toggleOffer(Occurrence $occurrence, Request $request)
{
$this->validate($request, [
'state' => 'required|boolean'
]);

$occurrence = Occurrence::findOrFail($id);
$occurrence->offer_sent = $request->get('state');
$occurrence->save();

return $occurrence->offer_sent;
}

public function togglePayment($id, Request $request)
public function togglePayment(Occurrence $occurrence, Request $request)
{
$this->validate($request, [
'state' => 'required|boolean'
]);

$occurrence = Occurrence::findOrFail($id);
var_dump($occurrence->occurs_at);

$occurrence->payment_received = $request->get('state');
$occurrence->save();

var_dump($occurrence->occurs_at);

return $occurrence->payment_received;
}

public function toggleReceipt($id, Request $request)
public function toggleReceipt(Occurrence $occurrence, Request $request)
{
$this->validate($request, [
'state' => 'required|boolean'
]);

$occurrence = Occurrence::findOrFail($id);
$occurrence->receipt_sent = $request->get('state');
$occurrence->save();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class FixOccurrencesOccursAtColumnByDroppingTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::drop('occurrences');

Schema::create('occurrences', function (Blueprint $table) {
$table->dateTime('occurs_at');
$table->boolean('offer_sent')->nullable();
$table->boolean('payment_received')->nullable();
$table->boolean('receipt_sent')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
$table->increments('id');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('occurrences');

Schema::create('occurrences', function (Blueprint $table) {
$table->timestamp('occurs_at');
$table->boolean('offer_sent')->nullable();
$table->boolean('payment_received')->nullable();
$table->boolean('receipt_sent')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
$table->increments('id');
$table->timestamps();
});
}
}

0 comments on commit c98c219

Please sign in to comment.