File tree Expand file tree Collapse file tree 3 files changed +71
-2
lines changed Expand file tree Collapse file tree 3 files changed +71
-2
lines changed Original file line number Diff line number Diff line change 22
33namespace Webfactor \Laravel \Backpack \Documents \Controllers ;
44
5+ use Illuminate \Http \Request ;
56use Spatie \Fractalistic \ArraySerializer ;
67use Webfactor \Laravel \ApiController \ApiController ;
78use Webfactor \Laravel \Backpack \Documents \Transformers \DocumentTransformer ;
@@ -14,8 +15,12 @@ class DocumentApiController extends ApiController
1415 *
1516 * @return \Illuminate\Http\JsonResponse
1617 */
17- public function index ()
18+ public function index (Request $ request )
1819 {
20+ if ($ lang = $ request ->input ('lang ' )) {
21+ \App::setLocale ($ lang );
22+ }
23+
1924 $ model = config ('webfactor.documents.model_class ' );
2025
2126 $ documents = $ model ::all ();
Original file line number Diff line number Diff line change 44
55use Backpack \CRUD \app \Http \Controllers \CrudController ;
66use Webfactor \Laravel \Backpack \Documents \Requests \DocumentRequest as StoreRequest ;
7- use Webfactor \Laravel \Backpack \Documents \Requests \DocumentRequest as UpdateRequest ;
7+ use Webfactor \Laravel \Backpack \Documents \Requests \DocumentUpdateRequest as UpdateRequest ;
88
99class DocumentCrudController extends CrudController
1010{
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Webfactor \Laravel \Backpack \Documents \Requests ;
4+
5+ use App \Http \Requests \Request ;
6+ use Illuminate \Validation \Rule ;
7+
8+ class DocumentUpdateRequest extends \Backpack \CRUD \app \Http \Requests \CrudRequest
9+ {
10+ /**
11+ * Determine if the user is authorized to make this request.
12+ *
13+ * @return bool
14+ */
15+ public function authorize ()
16+ {
17+ // only allow updates if the user is logged in
18+ return \Auth::check ();
19+ }
20+
21+ /**
22+ * Get the validation rules that apply to the request.
23+ *
24+ * @return array
25+ */
26+ public function rules ()
27+ {
28+ return [
29+ 'type ' => [
30+ 'required ' ,
31+ Rule::in (config ('webfactor.documents.types ' )),
32+ Rule::unique ('documents ' )->ignore ($ this ->id )
33+ ],
34+ 'title ' => 'required|min:5|max:255 ' ,
35+ 'body ' => 'required|string '
36+ ];
37+ }
38+
39+ /**
40+ * Get the validation attributes that apply to the request.
41+ *
42+ * @return array
43+ */
44+ public function attributes ()
45+ {
46+ return [
47+ 'type ' => trans ('webfactor::documents.type ' ),
48+ 'title ' => trans ('webfactor::documents.title ' ),
49+ 'body ' => trans ('webfactor::documents.body ' )
50+ ];
51+ }
52+
53+ /**
54+ * Get the validation messages that apply to the request.
55+ *
56+ * @return array
57+ */
58+ public function messages ()
59+ {
60+ return [
61+ //
62+ ];
63+ }
64+ }
You can’t perform that action at this time.
0 commit comments