# 其他助手函數
#### [](https://octobercms.com/docs/services/helpers#method-asset)`asset()`
使用當前請求方案(HTTP或HTTPS)生成資產的URL:
~~~
$url = asset('img/photo.jpg');
~~~
#### [](https://octobercms.com/docs/services/helpers#method-config)`config()`
該`config`函數獲取配置變量的值。可以使用“點”語法訪問配置值,該語法包括文件名和您希望訪問的選項。如果配置選項不存在,則可以指定默認值并返回:
~~~
$value = config('app.timezone');
$value = config('app.timezone', $default);
~~~
的`config`輔助,也可以通過使鍵/值對的陣列用于設置配置變量在運行時:
~~~
config(['app.debug' => true]);
~~~
#### [](https://octobercms.com/docs/services/helpers#method-dd)`dd()`
該`dd`函數轉儲給定的變量并結束腳本的執行:
~~~
dd($value);
~~~
#### [](https://octobercms.com/docs/services/helpers#method-env)`env()`
該`env`函數獲取環境變量的值或返回默認值:
~~~
$env = env('APP_ENV');
// Return a default value if the variable doesn't exist...
$env = env('APP_ENV', 'production');
~~~
#### [](https://octobercms.com/docs/services/helpers#method-get)`get()`
該`get`函數從請求中獲取輸入項,僅限于GET變量:
~~~
$value = get('key', $default = null)
~~~
#### [](https://octobercms.com/docs/services/helpers#method-input)`input()`
該`input`函數從請求中獲取輸入項:
~~~
$value = input('key', $default = null)
~~~
#### [](https://octobercms.com/docs/services/helpers#method-post)`post()`
該`post`函數從請求中獲取輸入項,僅限于POST變量:
~~~
$value = post('key', $default = null)
~~~
#### [](https://octobercms.com/docs/services/helpers#method-redirect)`redirect()`
該`redirect`函數返回重定向器的實例以進行[重定向響應](https://octobercms.com/docs/services/response-view#redirects):
~~~
return redirect('/home');
~~~
#### [](https://octobercms.com/docs/services/helpers#method-request)`request()`
該`request`函數返回當前[請求實例](https://octobercms.com/docs/services/request-input):
~~~
$referer = request()->header('referer');
~~~
#### [](https://octobercms.com/docs/services/helpers#method-response)`response()`
該`response`函數創建[響應](https://octobercms.com/docs/services/response-view)實例或獲取響應工廠的實例:
~~~
return response('Hello World', 200, $headers);
return response()->json(['foo' => 'bar'], 200, $headers);
~~~
#### [](https://octobercms.com/docs/services/helpers#method-route)`route()`
該`route`函數為給定的[命名路由](https://octobercms.com/docs/services/router)生成一個URL:
~~~
$url = route('routeName');
~~~
如果路由接受參數,則可以將它們作為方法的第二個參數傳遞:
~~~
$url = route('routeName', ['id' => 1]);
~~~
#### [](https://octobercms.com/docs/services/helpers#method-secure-asset)`secure_asset()`
使用HTTPS生成資產的URL:
~~~
echo secure_asset('foo/bar.zip', $title, $attributes = []);
~~~
#### [](https://octobercms.com/docs/services/helpers#method-trace-log)`trace_log()`
該`trace_log`函數將跟蹤消息寫入日志文件。
~~~
trace_log('This code has passed...');
~~~
該函數支持傳遞異常,數組和對象:
~~~
trace_log($exception);
trace_log($array);
trace_log($object);
~~~
您還可以傳遞多個參數來跟蹤多個消息:
~~~
trace_log($value1, $value2, $exception, '...');
~~~
#### [](https://octobercms.com/docs/services/helpers#method-trace-sql)`trace_sql()`
該`trace_sql`功能啟用數據庫日志記錄并開始監視所有SQL輸出。
~~~
trace_sql();
Db::table('users')->count();
// select count(*) as aggregate from users
~~~
#### [](https://octobercms.com/docs/services/helpers#method-url)`url()`
該`url`函數生成給定路徑的標準URL:
~~~
echo url('user/profile');
echo url('user/profile', [1]);
~~~
- 基本說明
- 基本操作
- October cms 安裝
- 后臺控制器路徑
- 圖標
- 獲取安裝網上的插件/主題
- 插件構造器使用
- 定時任務
- October后臺控制器
- vscode編輯器
- ajax操作
- 使用
- ajax更新組件
- ajax屬性API
- JavaScript API
- ajax綜合使用
- 主題
- 多語言主題
- 安裝市場主題
- 主題程序處理
- 主題
- 頁面
- 部件
- 布局
- 內容
- 組件
- 媒體
- 主題表單操作
- 表單使用
- 表單后端程序處理
- 插件
- 自定義插件
- 插件說明
- 插件導航條
- 插件數據庫設置
- 插件的設置管理
- 插件的配置文件config
- 組件
- app服務
- app容器
- 擴展行為
- 緩存
- Collection類
- Lazy Collections
- Collection方法
- 助手函數
- 數組助手函數
- 路徑助手函數
- 玄樂助手函數
- 其他助手函數
- 錯誤與記錄
- 事件處理
- HTML頁面
- 文件與目錄操作
- 散列和加密
- 郵件
- 郵件內容
- 郵件發送
- 分頁
- 模板解析器
- 動態解析器語法
- 隊列消息
- 請求與輸入
- 響應
- 視圖
- 路由器
- 配置
- 驗證操作
- 處理錯誤消息
- 錯誤消息與視圖
- 可用的驗證規則
- 有條件的驗證規則
- 驗證數組
- 錯誤消息
- 自定義驗證規則
- 模型操作
- 定義模型與其屬性
- 檢索模型
- 插入與更新
- 刪除模型
- 查詢范圍
- 事件操作
- 關聯操作
- 定義關系
- 關系類型
- 多肽關系
- 關系查詢
- 渴望加載
- 插入模型
- 數據庫操作
- 基本用法
- 數據表結構
- 查詢連貫操作
- 結果檢索
- select子句
- 插入更新
- where子句
- 排序,分組,限制和偏移
- 文件附件
- Collection操作
- 屬性操作
- 系列化json
- 數據庫屬性
- 數據庫行為
- 控制器
- 后臺控制器定義
- 后臺頁面
- 后臺組件
- 后臺表單
- 表單組件
- 表單視圖
- 表單行為
- 后臺列表
- 列表行為
- 列表過濾器
- 可用列類型
- 關系行為
- 關系行為類型
- 擴展關系行為
- 列表排序操作
- 導入導出操作
- 用于與權限
- corlate模板修改
- 修改頂部導航
- laravel問題
- 控制器不存在
- 控制器
- 路由組
- laravel筆記
- laravel 安裝
- 偽靜態配置
- 依賴注入 & 控制器
- 中間件
- 路由文件
- 視圖