Here is my code, for some reason, my code got flagged as spam. :/
class RegisterRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|min:3',
'email' => 'required',
'password' => 'required|min:6'
];
}
You can pass back a json response with Response::json .
Assuming you are only replying in json with a model called Url.php
App\Http\Controllers\UrlController.php
public function store()
{
$url = new Url;
$url->url = Request::get('url');
$url->description = Request::get('description');
$url->user_id = Auth::user()->id;
// normal validation and filtering
$url->save();
return Response::json(array(
'error' => false,
'urls' => $urls->toArray()),
200
);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community