# 常用語法

## 新增控制器

參考文件 => <https://laravel.tw/docs/5.2/controllers#restful-resource-controllers>

```
php artisan make:controller LabController

//以下這是laravel自己作的一種
php artisan make:controller DataController --resource
//搭配以下route使用
Route::resource('data', 'DataController');
```

## 新增資料表

```
php artisan make:model Employee -m
```

## 新增migrations

```
php artisan migrate
```

## 使用tinker工具程式

```
php artisan tinker
```

## 將form當作delete送出

```php
<form method="post" action="/employees/{{$emp->id}}"> 
    <a href="/employees/{{$emp->id}}/edit" class="btn btn-xs btn-info"><span class="glyphicon glyphicon-pencil"></span> 修改</a> | 
    @csrf
    {{-- 加上以下這串可以將form表單以刪除方式送出 --}}
    @method('DELETE') 
    <button type="submit" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-remove"></span> 刪除</button>
</form>
```

## 將form當作put送出

```php
<form method="post" action="/employees/{{$emp->id}}"> 
    <a href="/employees/{{$emp->id}}/edit" class="btn btn-xs btn-info"><span class="glyphicon glyphicon-pencil"></span> 修改</a> | 
    @csrf
    {{-- 加上以下這串可以將form表單以刪除方式送出 --}}
    @method('PUT')
    <button type="submit" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-remove"></span> 刪除</button>
</form>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tobyisme.gitbook.io/laravel/chang-yong-yu-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
