> For the complete documentation index, see [llms.txt](https://tobyisme.gitbook.io/laravel/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tobyisme.gitbook.io/laravel/chang-yong-yu-fa.md).

# 常用語法

## 新增控制器

參考文件 => <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>
```
