Laravel
  • Introduction
  • 常用語法
  • 結合Vue.js從無到有架設一個網站
  • 透過CMD新增File
  • Schedule
  • Annotation
  • Super Variable
  • API的設定
  • Create 新專案
  • Raw Expressions
  • Import - Export
  • JWT 外加 登入功能
  • Carbon
  • Storage 保存文件
  • Require_once
  • 設定apache將laravel專案run起來
  • 有關leftjoin的用法
  • Advanced Join Clauses
  • Call API方式
  • 產生新的APP_KEY
  • 程序優化技巧
  • composer update VS 手動丟檔
  • 全域變數被使用過
  • FB的SDK
Powered by GitBook
On this page
  • 新增控制器
  • 新增資料表
  • 新增migrations
  • 使用tinker工具程式
  • 將form當作delete送出
  • 將form當作put送出

Was this helpful?

常用語法

PreviousIntroductionNext結合Vue.js從無到有架設一個網站

Last updated 5 years ago

Was this helpful?

新增控制器

參考文件 =>

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送出

<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送出

<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>
https://laravel.tw/docs/5.2/controllers#restful-resource-controllers