use BookStack\Page;
use BookStack\Services\PermissionService;
use BookStack\User;
+use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
class EntityRepo
*/
public function getUserDraftPages($count = 20, $page = 0)
{
- $user = auth()->user();
return $this->page->where('draft', '=', true)
- ->where('created_by', '=', $user->id)
+ ->where('created_by', '=', user()->id)
->orderBy('updated_at', 'desc')
->skip($count * $page)->take($count)->get();
}
return $query;
}
+ /**
+ * Alias method to update the book jointPermissions in the PermissionService.
+ * @param Collection $collection collection on entities
+ */
+ public function buildJointPermissions(Collection $collection)
+ {
+ $this->permissionService->buildJointPermissionsForEntities($collection);
+ }
+
+ /**
+ * Format a name as a url slug.
+ * @param $name
+ * @return string
+ */
+ protected function nameToSlug($name)
+ {
+ $slug = str_replace(' ', '-', strtolower($name));
+ $slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', $slug);
+ if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5);
+ return $slug;
+ }
+
}