@@ -16,6 +16,8 @@ trait EloquentDatatable
1616
1717 protected bool $ allowCreation = true ;
1818
19+ protected bool $ allowEditing = true ;
20+
1921 protected bool $ createUsingDialog = false ;
2022
2123 protected bool $ allowSearching = true ;
@@ -51,10 +53,11 @@ public function getResponse(Request $request): array
5153 'name ' => $ this ->getDataTableName (),
5254 'name_singular ' => Str::singular ($ this ->getDataTableName ()),
5355 'allow ' => [
54- 'deletions ' => $ this ->allowDeletion ,
5556 'creation ' => $ this ->allowCreation ,
56- 'searching ' => $ this ->allowSearching ,
5757 'create_with_dialog ' => $ this ->createUsingDialog ,
58+ 'editing ' => $ this ->allowEditing ,
59+ 'deletions ' => $ this ->allowDeletion ,
60+ 'searching ' => $ this ->allowSearching ,
5861 ],
5962 'pagination_limit ' => $ this ->getLimit ($ request ),
6063 ],
@@ -106,10 +109,8 @@ protected function getTableColumns(): array
106109 $ columns = $ builder ->getColumnListing ($ table );
107110 $ columnsWithType = collect ($ columns )->mapWithKeys (function ($ item ) use ($ builder , $ table ) {
108111 $ key = $ builder ->getColumnType ($ table , $ item );
109-
110112 return [$ item => $ key ];
111113 });
112-
113114 return $ columnsWithType ->toArray ();
114115 }
115116
@@ -179,7 +180,9 @@ protected function itemStore(array $array): void
179180
180181 protected function itemUpdate (int $ id , array $ array ): void
181182 {
182- $ this ->builder ->findOrFail ($ id )->update ($ array );
183+ if ($ this ->allowEditing ) {
184+ $ this ->builder ->findOrFail ($ id )->update ($ array );
185+ }
183186 }
184187
185188 /**
0 commit comments