Do you say to build common functions inside the controllerReservations?

|
ldefra 2019-08-12 18:07:00
the method store of ControllerReservations can be called from several parts as well as here
ldefra 2019-08-12 18:08:09
do you say to build common functions inside the controllerReservations?
skys215 2019-08-12 18:25:25
Controller function shouldn’t be call in this way
skys215 2019-08-12 18:27:27
It’s like opening a can with a knife
skys215 2019-08-12 18:28:07
Use service layer or repository layer
GauravGohil 2019-08-12 18:31:34
$.ajax({
url: “/saved-templates/update”,
headers: {
‘X-CSRF-TOKEN’: $(‘meta[name=”csrf-token”]’).attr(‘content’)
},
method: “PATCH”,
data: formData,
dataType: ‘JSON’,
contentType: false,
cache: false,
processData: false,
GauravGohil 2019-08-12 18:31:43
when sending patch request via ajax
GauravGohil 2019-08-12 18:32:23
Request {#43
#json: null
GauravGohil 2019-08-12 18:32:36
in controller the response is null
ldefra 2019-08-12 18:40:29
skys215 2019-08-12 18:28:07
Use service layer or repository layer

ok check them

ldefra 2019-08-12 18:40:40
thanks, sorry for my english
MatPk 2019-08-12 18:40:59
hey
do you have a course about make crud with laravel vue?
skys215 2019-08-12 18:45:47
GauravGohil 2019-08-12 18:32:36
in controller the response is null

Dump the response

GauravGohil 2019-08-12 18:46:23
dd($request)
GauravGohil 2019-08-12 18:46:26
is showing null
skys215 2019-08-12 18:46:49
Request? Shouldn’t be response?
GauravGohil 2019-08-12 18:47:13
public function update(Request $request)
{
dd($request);
GauravGohil 2019-08-12 18:47:15
like this
GauravGohil 2019-08-12 18:47:23
it shows null
GauravGohil 2019-08-12 18:48:12
Request {#43
#json: null
#convertedFiles: null
#userResolver: Closure($guard = null) {#247
class: “IlluminateAuthAuthServiceProvider”
this: AuthServiceProvider {#52 …}
use: {
$app: Application {#2 …}
}
file: “F:laravelkraftnowvendorlaravelframeworksrcIlluminateAuthAuthServiceProvider.php”
line: “83 to 85”
}
#routeResolver: Closure() {#249
class: “IlluminateRoutingRouter”
this: Router {#26 …}
use: {
$route: Route {#210 …}
}
file: “F:laravelkraftnowvendorlaravelframeworksrcIlluminateRoutingRouter.php”
line: “650 to 652”
}
+attributes: ParameterBag {#45
#parameters: []
}
+request: ParameterBag {#44
#parameters: []
}
+query: ParameterBag {#51
#parameters: []
}
GauravGohil 2019-08-12 18:48:34
this is what dd($request) shows
skys215 2019-08-12 18:49:45
have you added the Aceept: application/json header or X-Requested-With: XMLHTTPRequest header?
GauravGohil 2019-08-12 18:50:14
no ihavenot
GauravGohil 2019-08-12 18:50:20
where should i do it
GauravGohil 2019-08-12 18:50:43
$.ajax({
url: “/saved-templates/update”,
headers: {
‘X-CSRF-TOKEN’: $(‘meta[name=”csrf-token”]’).attr(‘content’)
},
method: “PATCH”,
data: formData,
dataType: ‘JSON’,
contentType: false,
cache: false,
processData: false,
GauravGohil 2019-08-12 18:50:48
that is my ajc
GauravGohil 2019-08-12 18:50:49
ajax
skys215 2019-08-12 18:54:11
Add it in the headers section
GauravGohil 2019-08-12 18:55:51
ohk
GauravGohil 2019-08-12 18:59:41
what should i write in headers
skys215 2019-08-12 19:02:18
Accept: application/json
Or
X-Requested-With: XMLHTTPRequest
GauravGohil 2019-08-12 20:14:36
still its now working
GauravGohil 2019-08-12 20:14:43
not working
ldefra 2019-08-12 20:18:00
skys215 2019-08-12 18:28:07
Use service layer or repository layer

thanks, I’ve read some articles, the patterns are interesting but I don’t think it solves my problem

skys215 2019-08-13 03:45:07
You validate what you pass to the function inside the function, not through the request validator.
Run same validator in method A or validate yourself inside the method A and call service/repository to start the storing function
leonardosg 2019-08-13 03:48:59
Hey guys, i need some help with my code. I’m trying submit a form. But, it doesn’t work. The error is: “Method [validateName] does not exist”.
leonardosg 2019-08-13 03:49:42
laravel_discuss-10848.jpg
My code of controller.
zack6849 2019-08-13 03:51:29
why do you have it ‘required|name’
zack6849 2019-08-13 03:51:53
name isnt a valid validator, is it?
zack6849 2019-08-13 03:52:07
https://laravel.com/docs/5.8/validation#available-validation-rules

Laravel – The PHP Framework For Web ArtisansLaravel
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
zack6849 2019-08-13 03:52:21
should be one of those, maybe required|string?
zack6849 2019-08-13 03:52:37
you cant do alpha because spaces arent considered alpha
zack6849 2019-08-13 03:53:13
you could, however, use regex:
leonardosg 2019-08-13 04:01:34
I made a mistake. I was understood other thing about the validator method. After red the link that you sent me, i understood. Now, its work. 😁😁 Thanks for your help.
leonardosg 2019-08-13 04:02:04
I started with laravel this week ;D
zack6849 2019-08-13 04:02:14
no problem
rebory 2019-08-13 07:16:29
Hello everyone i need help
rebory 2019-08-13 07:17:17
laravel_discuss-10859.jpg
This is blade form
rebory 2019-08-13 07:17:31
Where i create some dynamic inputs
rebory 2019-08-13 07:17:43
And
|