Created
August 20, 2015 20:51
-
-
Save galileoguzman/fac13372c9fad1f8366c to your computer and use it in GitHub Desktop.
Controller of Ticket Object from ticket system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use App\Http\Controllers\Controller; | |
use App\MayestroModels\Ticket; | |
use App\MayestroModels\Category; | |
class TicketController extends Controller | |
{ | |
public function store(Request $request) | |
{ | |
// | |
if($request->ajax() && $request->method('post')){ | |
//Get all inputs of Request | |
$data = $request->all(); | |
//Application logic | |
$t = new Ticket(); | |
$t->title = $data['title']; | |
$t->description = $data['description']; | |
$t->id_category = $data['category']; | |
$t->id_user = 1; | |
$t->status = true; | |
if($t->save()){ | |
$response = array( | |
'message' => 'Ticket de Servicio '.$data['title'].' guardado correctamente.', | |
'response_code' => 200, | |
'data' => $data | |
); | |
}else{ | |
$response = array( | |
'message' => 'No se pudo guardar el Ticket '.$data['title'].' en la aplicación, intente más tarde.', | |
'response_code' => 201, | |
'data' => $data | |
); | |
} | |
}else{ | |
$response = array( | |
'message' => 'Estoy confundido, ¿Qué estas buscando?', | |
'response_code' => 300 | |
); | |
} | |
// API Response | |
return response()->json($response); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment