diff --git a/app/config/examples/database.php b/app/config/examples/database.php index 8035cf6..684622b 100644 --- a/app/config/examples/database.php +++ b/app/config/examples/database.php @@ -23,9 +23,10 @@ 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', - 'database' => '', - 'username' => '', - 'password' => '', + 'database' => 'purchases', + 'username' => 'homestead', + 'password' => 'secret', + 'charset' => 'utf8', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => '', diff --git a/app/config/session.php b/app/config/session.php index 059a939..b5a6c22 100644 --- a/app/config/session.php +++ b/app/config/session.php @@ -16,7 +16,7 @@ | */ - 'driver' => 'database', + 'driver' => 'file', /* |-------------------------------------------------------------------------- diff --git a/app/controllers/api/PurchaseStatusController.php b/app/controllers/api/PurchaseStatusController.php new file mode 100644 index 0000000..44aca05 --- /dev/null +++ b/app/controllers/api/PurchaseStatusController.php @@ -0,0 +1,137 @@ + [] + ]; + + $purSt = PurchaseStatus::all(); + + foreach($purSt as $pS){ + + $response['PurchaseStatuses'][] = [ + 'id' => $pS->id, + 'name' => $pS->name + ]; + } + + }catch (Exception $e){ + $statusCode = 400; + }finally{ + var_dump($response); + return Response::json($response, $statusCode); + } + + } + + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function create() + { + // + } + + + /** + * Store a newly created resource in storage. + * + * @return Response + */ + public function store() + { + // + $input = Input::all(); + var_dump($input); + $purSt = new PurchaseStatus(); + $purSt->name = $input['name']; + $purSt->save(); + } + + + /** + * Display the specified resource. + * + * @param int $id + * @return Response + */ + public function show($id) + { + // + try{ + $purSt = PurchaseStatus::find($id); + $statusCode = 200; + $response = [ + 'PurchaseStatuses' => ['id' => $purSt->id, + 'name' => $purSt->name + ]]; + }catch (Exception $e){ + $statusCode = 400; + $response = [ + "error" => "Status doesn`t exists" + ]; + }finally{ + var_dump($response); + return Response::json($response, $statusCode); + } + } + + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return Response + */ + public function edit($id) + { + // + } + + + /** + * Update the specified resource in storage. + * + * @param int $id + * @return Response + */ + public function update($id) + { + // + } + + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return Response + */ + public function destroy($id) + { + // + } + + +} diff --git a/app/models/PurchaseStatus.php b/app/models/PurchaseStatus.php index e07222f..fddb5bc 100644 --- a/app/models/PurchaseStatus.php +++ b/app/models/PurchaseStatus.php @@ -6,6 +6,9 @@ * Date: 06.11.2014 * Time: 1:07 */ +namespace Goros6\Purchases\Models; +use Eloquent; + class PurchaseStatus extends Eloquent { public $timestamps = false; diff --git a/app/routes.php b/app/routes.php index 3e10dcf..a44f837 100644 --- a/app/routes.php +++ b/app/routes.php @@ -15,3 +15,8 @@ { return View::make('hello'); }); + +Route::group(array('prefix' => 'v1/api'), function() { + Route::resource('purchaseStatus', 'Goros6\\Purchases\\Controllers\\Api\\PurchaseStatusController'); +}); + diff --git a/composer.json b/composer.json index 72a75d7..e56e21e 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,11 @@ "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php" - ] + ], + "psr-4":{ + "Goros6\\Purchases\\Controllers\\api\\": "app/controllers/api", + "Goros6\\Purchases\\Models\\": "app/models" + } }, "scripts": { "post-install-cmd": [